diff options
author | Henrik Paul <henrik@vaadin.com> | 2015-03-25 18:04:45 +0200 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2015-03-27 07:51:12 +0000 |
commit | e191abb0da9e4660e925991490e967c178380aef (patch) | |
tree | 3d8542557f6fd7d83a77d92367b3fab2f244ef84 /server/src/com/vaadin/data/RpcDataProviderExtension.java | |
parent | eb3406247e397c23d447bf4fd84a5052a0488876 (diff) | |
download | vaadin-framework-e191abb0da9e4660e925991490e967c178380aef.tar.gz vaadin-framework-e191abb0da9e4660e925991490e967c178380aef.zip |
Fixed some faulty asserts in Grid's detail row creation (#17293)
Change-Id: I8e9998524c02ca1e2f9d3391fa27bacc53655c7f
Diffstat (limited to 'server/src/com/vaadin/data/RpcDataProviderExtension.java')
-rw-r--r-- | server/src/com/vaadin/data/RpcDataProviderExtension.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/server/src/com/vaadin/data/RpcDataProviderExtension.java b/server/src/com/vaadin/data/RpcDataProviderExtension.java index 217b2fe392..e645ec60f7 100644 --- a/server/src/com/vaadin/data/RpcDataProviderExtension.java +++ b/server/src/com/vaadin/data/RpcDataProviderExtension.java @@ -663,8 +663,10 @@ public class RpcDataProviderExtension extends AbstractExtension { assert itemId != null : "itemId was null"; Integer newRowIndex = Integer.valueOf(rowIndex); - assert !visibleDetailsComponents.containsKey(itemId) : "itemId " - + "already has a component. Should be destroyed first."; + if (visibleDetailsComponents.containsKey(itemId)) { + // Don't overwrite existing components + return; + } RowReference rowReference = new RowReference(grid); rowReference.set(itemId); @@ -695,14 +697,8 @@ public class RpcDataProviderExtension extends AbstractExtension { + "itemId is empty even though we just created a " + "component for it (" + itemId + ")"; } else { - assert !emptyDetails.containsKey(itemId) : "Bookkeeping has " - + "already itemId marked as empty (itemId: " + itemId - + ", old index: " + emptyDetails.get(itemId) - + ", new index: " + newRowIndex + ")"; - assert !emptyDetails.containsValue(newRowIndex) : "Bookkeeping" - + " already had another itemId for this empty index " - + "(index: " + newRowIndex + ", new itemId: " + itemId - + ")"; + assert assertItemIdHasNotMovedAndNothingIsOverwritten(itemId, + newRowIndex); emptyDetails.put(itemId, newRowIndex); } @@ -712,6 +708,26 @@ public class RpcDataProviderExtension extends AbstractExtension { */ } + private boolean assertItemIdHasNotMovedAndNothingIsOverwritten( + Object itemId, Integer newRowIndex) { + + Integer oldRowIndex = emptyDetails.get(itemId); + if (!SharedUtil.equals(oldRowIndex, newRowIndex)) { + + assert !emptyDetails.containsKey(itemId) : "Unexpected " + + "change of empty details row index for itemId " + + itemId + " from " + oldRowIndex + " to " + + newRowIndex; + + assert !emptyDetails.containsValue(newRowIndex) : "Bookkeeping" + + " already had another itemId for this empty index " + + "(index: " + newRowIndex + ", new itemId: " + itemId + + ")"; + } + + return true; + } + /** * Destroys correctly a details component, by the request of the client * side. |