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>
This commit is contained in:
Edwin Kempin 2017-03-09 15:55:16 +01:00
parent 2dbb936d16
commit 29a8cb0fe4
1 changed files with 5 additions and 2 deletions

View File

@ -67,8 +67,11 @@ public class AuthInfo extends JavaScriptObject {
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;
}