From 42861a8a47d1e3c6fd157210d96e664020bf83eb Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Wed, 4 Nov 2015 15:39:46 -0500 Subject: [PATCH] Handle null from Gerrit#getDiffPreferences() Change-Id: Ib6500a1cf55e799b5375ec8e92d82354799fafe5 --- .../java/com/google/gerrit/client/account/DiffPreferences.java | 3 +++ .../java/com/google/gerrit/client/diff/PreferencesBox.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java index 07d45e9ab4..b1f05f81e3 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java @@ -21,6 +21,9 @@ import com.google.gwt.core.client.JavaScriptObject; public class DiffPreferences extends JavaScriptObject { public static DiffPreferences create(DiffPreferencesInfo in) { + if (in == null) { + in = DiffPreferencesInfo.defaults(); + } DiffPreferences p = createObject().cast(); p.ignoreWhitespace(in.ignoreWhitespace); p.tabSize(in.tabSize); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java index a50768db49..455a6437eb 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java @@ -503,7 +503,7 @@ public class PreferencesBox extends Composite { AccountApi.putDiffPreferences(prefs, new GerritCallback() { @Override public void onSuccess(DiffPreferences result) { - DiffPreferencesInfo p = Gerrit.getDiffPreferences(); + DiffPreferencesInfo p = new DiffPreferencesInfo(); result.copyTo(p); Gerrit.setDiffPreferences(p); }