From f5e2275e70a42817c4786657c385f8213ec365ee Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 19 Oct 2015 14:43:06 +0300 Subject: Fix Grid NPE when deselecting already removed row (#19152) Change-Id: I1361c8099e9f4a95e991f4937a406c5e4db67027 --- .../communication/data/RpcDataProviderExtension.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'server/src/com') diff --git a/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java b/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java index e3c48f1ec0..fed31646f4 100644 --- a/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java +++ b/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java @@ -367,15 +367,17 @@ public class RpcDataProviderExtension extends AbstractExtension { for (int i = 0; i < newRange.length() && i + diff < itemIds.size(); ++i) { Object itemId = itemIds.get(i + diff); - rows.set(i, getRowData(getGrid().getColumns(), itemId)); + Item item = container.getItem(itemId); + + rows.set(i, getRowData(getGrid().getColumns(), itemId, item)); } rpc.setRowData(firstRowToPush, rows); activeItemHandler.addActiveItems(itemIds); } - private JsonObject getRowData(Collection columns, Object itemId) { - Item item = container.getItem(itemId); + private JsonObject getRowData(Collection columns, Object itemId, + Item item) { final JsonObject rowObject = Json.createObject(); for (DataGenerator dg : dataGenerators) { @@ -497,12 +499,16 @@ public class RpcDataProviderExtension extends AbstractExtension { return; } + List columns = getGrid().getColumns(); JsonArray rowData = Json.createArray(); int i = 0; for (Object itemId : itemIds) { if (activeItemHandler.getActiveItemIds().contains(itemId)) { - JsonObject row = getRowData(getGrid().getColumns(), itemId); - rowData.set(i++, row); + Item item = container.getItem(itemId); + if (item != null) { + JsonObject row = getRowData(columns, itemId, item); + rowData.set(i++, row); + } } } rpc.updateRowData(rowData); -- cgit v1.2.3