diff options
author | Bogdan Udrescu <bogdan@vaadin.com> | 2014-07-29 14:40:40 +0300 |
---|---|---|
committer | Bogdan Udrescu <bogdan@vaadin.com> | 2014-07-29 14:40:40 +0300 |
commit | 97a115bf3981d32e601b7a794bc1087308107bcf (patch) | |
tree | fe2390c25a94d6ecb696e7e6cd49a3f82bb091e0 | |
parent | 39c3ab667db7ab7b2aa9cb4449e4ccad840135b3 (diff) | |
download | vaadin-framework-97a115bf3981d32e601b7a794bc1087308107bcf.tar.gz vaadin-framework-97a115bf3981d32e601b7a794bc1087308107bcf.zip |
Revert "Add asserts checking for negative container sizes (#14232)"
This reverts commit c43ebbac50a55e965738ec82c83a3fe08636b911.
Reverted because it might actually break some theoretically broken
applications that still happen to work by chance.
6 files changed, 2 insertions, 69 deletions
diff --git a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index 0bfec33957..eafd3573bc 100644 --- a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -701,9 +701,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, */ @Override public int size() { - int size = container.size(); - assert size >= 0; - return size; + return container.size(); } /* diff --git a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java index 4bb4e4c1b2..483753da88 100644 --- a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java @@ -494,7 +494,6 @@ public class ContainerOrderedWrapper implements Container.Ordered, @Override public int size() { int newSize = container.size(); - assert newSize >= 0; if (lastKnownSize != -1 && newSize != lastKnownSize && !(container instanceof Container.ItemSetChangeNotifier)) { // Update the internal cache when the size of the container changes diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index b083db3183..b8db329906 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -759,9 +759,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements */ @Override public int size() { - int size = items.size(); - assert size >= 0; - return size; + return items.size(); } /** diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index 5367505c56..048726dc84 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -354,7 +354,6 @@ public class ComboBox extends AbstractSelect implements if (pageLength == 0) { // no paging: return all items filteredSize = container.size(); - assert filteredSize >= 0; return new ArrayList<Object>(container.getItemIds()); } @@ -392,7 +391,6 @@ public class ComboBox extends AbstractSelect implements } filteredSize = container.size(); - assert filteredSize >= 0; currentPage = adjustCurrentPage(currentPage, needNullSelectOption, indexToEnsureInView, filteredSize); int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java index a8804caedb..7c19395df2 100644 --- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java +++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java @@ -262,7 +262,6 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, private int[] getFirstAndLastEventIndex(Date start, Date end) { int startIndex = 0; int size = container.size(); - assert size >= 0; int endIndex = size - 1; if (start != null) { diff --git a/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java b/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java deleted file mode 100644 index 04fd8d3cd1..0000000000 --- a/server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.data.util; - -import org.junit.Test; - -import com.vaadin.data.Container; -import com.vaadin.ui.Table; - -public class ContainerSizeAssertTest { - - @Test(expected = AssertionError.class) - public void testNegativeSizeAssert() { - Table table = createAttachedTable(); - - table.setContainerDataSource(createNegativeSizeContainer()); - } - - @Test - public void testZeroSizeNoAssert() { - Table table = createAttachedTable(); - - table.setContainerDataSource(new IndexedContainer()); - } - - private Container createNegativeSizeContainer() { - return new IndexedContainer() { - @Override - public int size() { - return -1; - } - }; - } - - private Table createAttachedTable() { - return new Table() { - private boolean initialized = true; - - @Override - public boolean isAttached() { - // This returns false until the super constructor has finished - return initialized; - } - }; - } -} |