Handle null/undefined JsArrays as empty in Natives.asList()
Fix a resulting bug in PublishCommentScreen causing an error when nobody has voted on a particular label. Change-Id: I0c6bfbfa4ea151df4e9b588251fd1895745a7edb
This commit is contained in:
@@ -267,10 +267,12 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
vp.setStyleName(Gerrit.RESOURCES.css().approvalCategoryList());
|
||||
|
||||
Short prior = null;
|
||||
for (ApprovalInfo app : Natives.asList(label.all())) {
|
||||
if (app._account_id() == Gerrit.getUserAccount().getId().get()) {
|
||||
prior = app.value();
|
||||
break;
|
||||
if (label.all() != null) {
|
||||
for (ApprovalInfo app : Natives.asList(label.all())) {
|
||||
if (app._account_id() == Gerrit.getUserAccount().getId().get()) {
|
||||
prior = app.value();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,9 @@ public class Natives {
|
||||
|
||||
public static <T extends JavaScriptObject> List<T> asList(
|
||||
final JsArray<T> arr) {
|
||||
if (arr == null) {
|
||||
return null;
|
||||
}
|
||||
return new AbstractList<T>() {
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
|
Reference in New Issue
Block a user