]> source.dussan.org Git - vaadin-framework.git/commitdiff
Revert "Add asserts checking for negative container sizes (#14232)"
authorBogdan Udrescu <bogdan@vaadin.com>
Tue, 29 Jul 2014 11:40:40 +0000 (14:40 +0300)
committerBogdan Udrescu <bogdan@vaadin.com>
Tue, 29 Jul 2014 11:40:40 +0000 (14:40 +0300)
This reverts commit c43ebbac50a55e965738ec82c83a3fe08636b911.

Reverted because it might actually break some theoretically broken
applications that still happen to work by chance.

server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java
server/src/com/vaadin/data/util/ContainerOrderedWrapper.java
server/src/com/vaadin/ui/AbstractSelect.java
server/src/com/vaadin/ui/ComboBox.java
server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
server/tests/src/com/vaadin/data/util/ContainerSizeAssertTest.java [deleted file]

index 0bfec339574d9be02864997aab84c379535928e1..eafd3573bce85558fdb81f142f88774d96f52824 100644 (file)
@@ -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();
     }
 
     /*
index 4bb4e4c1b2fa21dd7b5a3b7a0920ff3217c6ef9a..483753da8864568b8b8e2c27c319418d7078d487 100644 (file)
@@ -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
index b083db3183214e48b16cc98c07da3f08d62cb646..b8db32990609b78b4d53c83d862cd9ddb1487a61 100644 (file)
@@ -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();
     }
 
     /**
index 5367505c566fc29415b3e8dda2d66d80257e5b6e..048726dc843cff41d398ec216ef5147fa2769a32 100644 (file)
@@ -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,
index a8804caedb3b673b69abfa5f55e300ba0ff6955d..7c19395df2947f56cd1a75de36f9ff6b3f4d8835 100644 (file)
@@ -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 (file)
index 04fd8d3..0000000
+++ /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;
-            }
-        };
-    }
-}