From 05fa102f874cc3dc1dcea1191d1a4eabc8f6125b Mon Sep 17 00:00:00 2001 From: Ilia Motornyi Date: Fri, 30 Jun 2017 10:59:13 +0300 Subject: Fix bookkeeping assertion error Fixes #9584 --- .../com/vaadin/data/provider/DataCommunicator.java | 1 + .../vaadin/data/provider/DataCommunicatorTest.java | 23 ++++++++++++++++++++++ shared/src/main/java/com/vaadin/shared/Range.java | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java index 0971c36755..054e86ca8d 100644 --- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java @@ -185,6 +185,7 @@ public class DataCommunicator extends AbstractExtension { @Override public void destroyAllData() { + droppedData.clear(); activeData.clear(); getKeyMapper().removeAll(); } diff --git a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java index 1e75d57263..c6d80e6ab0 100644 --- a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java +++ b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java @@ -18,6 +18,8 @@ package com.vaadin.data.provider; import java.util.Collections; import java.util.concurrent.Future; +import elemental.json.Json; +import elemental.json.JsonArray; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -191,4 +193,25 @@ public class DataCommunicatorTest { TEST_OBJECT, generator.generated); } + @Test + public void testDestroyData() { + session.lock(); + UI ui = new TestUI(session); + TestDataCommunicator communicator = new TestDataCommunicator(); + TestDataProvider dataProvider = new TestDataProvider(); + communicator.setDataProvider(dataProvider, null); + communicator.extend(ui); + // Put a test object into a cache + communicator.pushData(1, Collections.singletonList(TEST_OBJECT)); + // Drop the test object from the cache + String key = communicator.getKeyMapper().key(TEST_OBJECT); + JsonArray keys = Json.createArray(); + keys.set(0,key); + communicator.onDropRows(keys); + // Drop everything + communicator.dropAllData(); + // The communicator does not have to throw exceptions during + // request finalization + communicator.beforeClientResponse(false); + } } diff --git a/shared/src/main/java/com/vaadin/shared/Range.java b/shared/src/main/java/com/vaadin/shared/Range.java index 49458d848b..3f670ca28c 100644 --- a/shared/src/main/java/com/vaadin/shared/Range.java +++ b/shared/src/main/java/com/vaadin/shared/Range.java @@ -229,7 +229,7 @@ public final class Range implements Serializable { @Override public String toString() { return getClass().getSimpleName() + " [" + getStart() + ".." + getEnd() - + "[" + (isEmpty() ? " (empty)" : ""); + + "]" + (isEmpty() ? " (empty)" : ""); } @Override -- cgit v1.2.3