ReplyBox: Don't fail if permitted label is missing in labels

For ChangeInfo it is expected that all labels from the
'permitted_labels' field are contained in the 'labels' field. If this
was not the case the UI failed with the following error:

  SEVERE: Exception caught: (TypeError) : Cannot read property 'values' of undefined
  Class$S471: Exception caught: (TypeError) : Cannot read property 'values' of undefined
    at Unknown.Throwable_2(gerrit_ui-0.js)
    ...
  Caused by: Class$S171: (TypeError) : Cannot read property 'values' of undefined
    at Unknown.$_values(gerrit_ui-0.js)
    at Unknown.$values_0(gerrit_ui-0.js)
    at Unknown.$valueSet(gerrit_ui-0.js)
    at Unknown.renderLabels(gerrit_ui-0.js)
    at Unknown.ReplyBox(gerrit_ui-0.js)
    at Unknown.onReply_2(gerrit_ui-0.js)
    ...

This error prevents posting of replies on a change.

Although this should never happen, the UI should not fail like this.
Hence handle this case. This means the voting buttons for this label
would be missing, but at least posting a reply (other labels,
comments) is still working.

Change-Id: I27d3ce0784028c332378f6a390ab48d906fe35ea
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-10-26 14:04:51 +02:00
parent af1d440289
commit f543bd9bdf

View File

@@ -304,6 +304,9 @@ public class ReplyBox extends Composite {
for (String id : names) {
JsArrayString p = permitted.get(id);
if (p != null) {
if (!all.containsKey(id)) {
continue;
}
Set<Short> a = new TreeSet<>();
for (int i = 0; i < p.length(); i++) {
a.add(LabelInfo.parseValue(p.get(i)));