Merge branch 'stable-2.16'
* stable-2.16:
Check if approvals array is null before iterating
Change-Id: Iac4b5f078fcb176bfc5f2963c6edd46b09ca5dd4
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
index 0a1bfd1..603a554 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
@@ -129,8 +129,9 @@
CommentAddedEvent event, Map<String, String> common) {
common.putAll(propertyAttributeExtractor.extractFrom(event.author.get(), "commenter"));
common.put("comment", event.comment);
- if (event.approvals != null) {
- for (ApprovalAttribute approvalAttribute : event.approvals.get()) {
+ ApprovalAttribute[] approvals = event.approvals.get();
+ if (approvals != null) {
+ for (ApprovalAttribute approvalAttribute : approvals) {
common.putAll(propertyAttributeExtractor.extractFrom(approvalAttribute));
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
index 33e8aa6..bfaa949 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
@@ -211,6 +211,8 @@
ImmutableMap.of("revision", "testRevision", "patchSetNumber", "3");
expect(propertyAttributeExtractor.extractFrom(patchSetAttribute)).andReturn(patchSetProperties);
+ event.approvals = Suppliers.ofInstance(null);
+
event.comment = "testComment";
changeAttribute.project = "testProject";
changeAttribute.number = 176;