summaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-07-08 20:04:43 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2015-08-26 16:17:33 +0300
commit4665f13c0cbc548b167f03460c3ecd01f5999f3e (patch)
treea1909308797aa6d0e0a1445609db786c349d49be /server/src/com
parentea87dcb23565b3f21631cec8875eaf634c5963ca (diff)
downloadvaadin-framework-4665f13c0cbc548b167f03460c3ecd01f5999f3e.tar.gz
vaadin-framework-4665f13c0cbc548b167f03460c3ecd01f5999f3e.zip
Fix multiple book keeping problems in ContainerOrderedWrapper (#5934, #18422)
Change-Id: I138eef2ff9b1660dd545baee5df315ff135e0a91
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/data/util/ContainerOrderedWrapper.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java
index 4bb4e4c1b2..4329219e96 100644
--- a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java
+++ b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java
@@ -51,12 +51,14 @@ public class ContainerOrderedWrapper implements Container.Ordered,
private final Container container;
/**
- * Ordering information, ie. the mapping from Item ID to the next item ID
+ * Ordering information, ie. the mapping from Item ID to the next item ID.
+ * The last item id should not be present
*/
private Hashtable<Object, Object> next;
/**
- * Reverse ordering information for convenience and performance reasons.
+ * Reverse ordering information for convenience and performance reasons. The
+ * first item id should not be present
*/
private Hashtable<Object, Object> prev;
@@ -124,13 +126,21 @@ public class ContainerOrderedWrapper implements Container.Ordered,
first = nid;
}
if (last.equals(id)) {
- first = pid;
+ last = pid;
}
if (nid != null) {
- prev.put(nid, pid);
+ if (pid == null) {
+ prev.remove(nid);
+ } else {
+ prev.put(nid, pid);
+ }
}
if (pid != null) {
- next.put(pid, nid);
+ if (nid == null) {
+ next.remove(pid);
+ } else {
+ next.put(pid, nid);
+ }
}
next.remove(id);
prev.remove(id);
@@ -200,7 +210,7 @@ public class ContainerOrderedWrapper implements Container.Ordered,
final Collection<?> ids = container.getItemIds();
// Recreates ordering if some parts of it are missing
- if (next == null || first == null || last == null || prev != null) {
+ if (next == null || first == null || last == null || prev == null) {
first = null;
last = null;
next = new Hashtable<Object, Object>();
@@ -219,7 +229,7 @@ public class ContainerOrderedWrapper implements Container.Ordered,
// Adds missing items
for (final Iterator<?> i = ids.iterator(); i.hasNext();) {
final Object id = i.next();
- if (!next.containsKey(id)) {
+ if (!next.containsKey(id) && last != id) {
addToOrderWrapper(id);
}
}