diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-04 13:11:36 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-02-13 17:02:48 +0000 |
commit | 0225d0949b566dd6913aef44840cd9ae6c399c28 (patch) | |
tree | dd3d80d0097b0eee95eb2bd5d91c722ae28552cd /client/src | |
parent | d004aa1f8bbcc30ab58663b29c4945116256bb53 (diff) | |
download | vaadin-framework-0225d0949b566dd6913aef44840cd9ae6c399c28.tar.gz vaadin-framework-0225d0949b566dd6913aef44840cd9ae6c399c28.zip |
Fix AbstractRemoteDataSource cache clean up on remove (#19482)
Change-Id: Ib9fc54ef018afe7f571204aba41182333b77c47f
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/data/AbstractRemoteDataSource.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java index 380531694d..05ac7182c5 100644 --- a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java +++ b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java @@ -324,8 +324,10 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> { // Called after dropping from cache. Dropped row is passed as a // parameter, but is no longer present in the DataSource T removed = indexToRowMap.remove(Integer.valueOf(i)); - onDropFromCache(i, removed); - keyToIndexMap.remove(getRowKey(removed)); + if (removed != null) { + onDropFromCache(i, removed); + keyToIndexMap.remove(getRowKey(removed)); + } } } @@ -534,13 +536,15 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> { size -= count; + Range removedRange = Range.withLength(firstRowIndex, count); + dropFromCache(removedRange); + // shift indices to fill the cache correctly int firstMoved = Math.max(firstRowIndex + count, cached.getStart()); for (int i = firstMoved; i < cached.getEnd(); i++) { moveRowFromIndexToIndex(i, i - count); } - Range removedRange = Range.withLength(firstRowIndex, count); if (cached.isSubsetOf(removedRange)) { // Whole cache is part of the removal. Empty cache cached = Range.withLength(0, 0); |