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());
|
vp.setStyleName(Gerrit.RESOURCES.css().approvalCategoryList());
|
||||||
|
|
||||||
Short prior = null;
|
Short prior = null;
|
||||||
for (ApprovalInfo app : Natives.asList(label.all())) {
|
if (label.all() != null) {
|
||||||
if (app._account_id() == Gerrit.getUserAccount().getId().get()) {
|
for (ApprovalInfo app : Natives.asList(label.all())) {
|
||||||
prior = app.value();
|
if (app._account_id() == Gerrit.getUserAccount().getId().get()) {
|
||||||
break;
|
prior = app.value();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,6 +37,9 @@ public class Natives {
|
|||||||
|
|
||||||
public static <T extends JavaScriptObject> List<T> asList(
|
public static <T extends JavaScriptObject> List<T> asList(
|
||||||
final JsArray<T> arr) {
|
final JsArray<T> arr) {
|
||||||
|
if (arr == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new AbstractList<T>() {
|
return new AbstractList<T>() {
|
||||||
@Override
|
@Override
|
||||||
public T set(int index, T element) {
|
public T set(int index, T element) {
|
||||||
|
Reference in New Issue
Block a user