From 4c1919c6ec83ef60f44e688aafe83a2eaf25ef97 Mon Sep 17 00:00:00 2001 From: mlindfors Date: Mon, 4 Feb 2019 13:54:09 +0200 Subject: Fix an NPE caused by the previous fix to Grid's frozen columns (#11444) * Fix an NPE caused by the previous fix to Grid's frozen columns (#10653) If the user managed to get two frozen column count changes into a single server round-trip before the component had been attached, the previous fix #11346 lead to a null pointer exception since there was no diff state available. This fix adds a null check before removing the frozen column count value from the diff state so that this will not happen. Closes #10653 --- server/src/main/java/com/vaadin/ui/Grid.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 650bf7cab5..9ee57512b2 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -3232,8 +3232,12 @@ public class Grid extends AbstractListing implements HasComponents, final String diffStateKey = "frozenColumnCount"; UI ui = getUI(); if (ui != null) { - ui.getConnectorTracker().getDiffState(Grid.this) - .remove(diffStateKey); + JsonObject diffState = ui.getConnectorTracker() + .getDiffState(Grid.this); + // if diffState is not present, there's nothing for us to clean + if (diffState != null) { + diffState.remove(diffStateKey); + } } } getState().frozenColumnCount = numberOfColumns; -- cgit v1.2.3