Do not fail if patch set is not found
If a change ref is updated the plugin expects to find the
corresponding patch set in the database and fails if the patch set
cannot be found in the database.
Add a check for this case and do not fail, but instead ignore this ref
update and write a warning into the log.
This error happens if a change is rebased from the Gerrit WebUI
because Gerrit sends the ref-updated event for the change before it
creates the new patch set in the database.
Change-Id: Ie79fd5abace82a98bbc499031403b90443dcdde7
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/RefUpdateListener.java b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/RefUpdateListener.java
index 19d287d..335b355 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/RefUpdateListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/RefUpdateListener.java
@@ -120,6 +120,11 @@
PatchSet.Id psId = PatchSet.Id.fromRef(u.getRefName());
PatchSet ps = reviewDb.patchSets().get(psId);
+ if (ps == null) {
+ log.warn("No patch set found for " + u.getRefName());
+ continue;
+ }
+
final Change change = reviewDb.changes().get(psId.getParentKey());
if (change == null) {
log.warn("No change found for " + u.getRefName());