AuthInfo: Fix NullPointerException if there are no contributor agreements
The JavaScript exception is:
SEVERE: (TypeError) : Cannot read property 'iterator' of null
Class$S170: (TypeError) : Cannot read property 'iterator' of null
at Unknown.$contributorAgreements(gerrit_ui-4.js)
at Unknown.onLoad_19(gerrit_ui-4.js)
at Unknown.onAttach_0(gerrit_ui-0.js)
at Unknown.setParent(gerrit_ui-0.js)
...
Change-Id: I9de8ed23fbccf8987c871f36509f6f203a0ae73a
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/info/AuthInfo.java b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/info/AuthInfo.java
index 2f6ef79..c0ece8c 100644
--- a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/info/AuthInfo.java
+++ b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/info/AuthInfo.java
@@ -67,8 +67,11 @@
public final List<AgreementInfo> contributorAgreements() {
List<AgreementInfo> agreements = new ArrayList<>();
- for (AgreementInfo a : Natives.asList(_contributorAgreements())) {
- agreements.add(a);
+ JsArray<AgreementInfo> contributorAgreements = _contributorAgreements();
+ if (contributorAgreements != null) {
+ for (AgreementInfo a : Natives.asList(contributorAgreements)) {
+ agreements.add(a);
+ }
}
return agreements;
}