commit | 5f103c3bb9679a86e9c179f3c8172a12b1bbd401 | [log] [tgz] |
---|---|---|
author | Emmanuel Debanne <e.debanne@criteo.com> | Mon Aug 31 14:43:43 2015 +0200 |
committer | Emmanuel Debanne <e.debanne@criteo.com> | Mon Aug 31 15:28:47 2015 +0200 |
tree | 37b8096ea53ca4bccadde7f681c4a74edda8883a | |
parent | be8ad4929b24033c3ac772e0586bc8a74d2362c5 [diff] |
Fix NullPointerException when evaluating draft reviews This change in Gerrit introduced a bug for draft reviews: https://gerrit-review.googlesource.com/#/c/67762/3/gerrit-server/src/main/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java An NPE is thrown when the patchSet is not set before calling SubmitRuleEvaluator#evaluate(). This fix is a workaround until Gerrit is fixed. Change-Id: If531822421d501bd7970e03754d5ae5d8f3654ae
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java index b910113..e65d35e 100644 --- a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java +++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
@@ -108,7 +108,8 @@ */ public boolean isSubmittable(final int change) throws OrmException { final ChangeData changeData = changeDataFactory.create(db.get(), new Change.Id(change)); - final List<SubmitRecord> cansubmit = new SubmitRuleEvaluator(changeData).evaluate(); + // For draft reviews, the patchSet must be set to avoid an NPE. + final List<SubmitRecord> cansubmit = new SubmitRuleEvaluator(changeData).setPatchSet(changeData.currentPatchSet()).evaluate(); log.debug(String.format("Checking if change %d is submitable.", change)); for (final SubmitRecord submit : cansubmit) { if (submit.status != SubmitRecord.Status.OK) {