GetRelated: Handle index staleness for change on which the endpoint is invoked
To compute the related changes of a patch set we:
1. Get all the groups from the patch sets of the corresponding change.
2. Query for all changes in the project that have any of these groups.
The matched changes are then sorted by RelatedChangesSorter.
It is expected that the change for which the REST endpoint is invoked is
contained in the set of matched changes. Since we search by the change's
project and groups, it must always match.
However the index can be stale for that change in two ways:
1. The index knows the change but not yet the patch set for which the
REST endpoint is invoked.
2. The index does not yet know the change for which the REST endpoint is
invoked.
Case 1. was already handled by forcing a reload of the change when the
wanted patch set was not present in the ChangeData that was returned
from the index.
This change adds handling for case 2. If the change is missing in the
index result we now load its ChangeData from NoteDb and add it to the
result.
If the change is missing in the result then RelatedChangesSorter#sort
fails with a NullPointerException because it doesn't find a commit for
the given start patch set [1] (the commits are gathered from the given
change set which is missing the change for the start patch set).
[1]
java.lang.NullPointerException: commit b0f113907a693dbf911f5721afb5332647ed6990 of patch set 121,1 not found in {936be82cf638c033e1674c19b086bc0af8b07300=122,1, 2e5531ccee8872ddfb6595798416512f0fe6dec0=123,1}
at java.util.Objects.requireNonNull(Objects.java:290)
at com.google.gerrit.server.restapi.change.RelatedChangesSorter.sort(RelatedChangesSorter.java:80)
at com.google.gerrit.server.restapi.change.GetRelated.getRelated(GetRelated.java:103)
at com.google.gerrit.server.restapi.change.GetRelated.apply(GetRelated.java:76)
at com.google.gerrit.server.restapi.change.GetRelated.apply(GetRelated.java:52)
at com.google.gerrit.httpd.restapi.RestApiServlet.lambda$invokeRestReadViewWithRetry$3(RestApiServlet.java:741)
....
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I9a94d734aed5a84c8d9510f6fcc5baca4c3416e2
Gerrit is a code review and project management tool for Git based projects.
Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.
Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.
For information about how to install and use Gerrit, refer to the documentation.
Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.
Please report bugs on the issue tracker.
Gerrit is the work of hundreds of contributors. We appreciate your help!
Please read the contribution guidelines.
Note that we do not accept Pull Requests via the Github mirror.
The Developer Mailing list is repo-discuss on Google Groups.
Gerrit is provided under the Apache License 2.0.
Install Bazel and run the following:
git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
cd gerrit && bazel build release
The instruction how to configure GerritForge/BinTray repositories is here
On Debian/Ubuntu run:
apt-get update & apt-get install gerrit=<version>-<release>
NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.
On CentOS/RedHat run:
yum clean all && yum install gerrit-<version>[-<release>]
On Fedora run:
dnf clean all && dnf install gerrit-<version>[-<release>]
Docker images of Gerrit are available on DockerHub
To run a CentOS 7 based Gerrit image:
docker run -p 8080:8080 gerritforge/gerrit-centos7[:version]
To run a Ubuntu 15.04 based Gerrit image:
docker run -p 8080:8080 gerritforge/gerrit-ubuntu15.04[:version]
NOTE: release is optional. Last released package of the version is installed if the release number is omitted.