]> source.dussan.org Git - vaadin-framework.git/commitdiff
Return null as non-existing property for IndexedContainer (#10445) 39/439/1
authorHenri Sara <hesara@vaadin.com>
Fri, 30 Nov 2012 12:49:04 +0000 (14:49 +0200)
committerHenri Sara <hesara@vaadin.com>
Fri, 30 Nov 2012 12:49:04 +0000 (14:49 +0200)
Change-Id: I9829173dda84d5f496114b7d08204648bf86fc77

server/src/com/vaadin/data/util/IndexedContainer.java
server/tests/src/com/vaadin/data/util/TestIndexedContainer.java

index 81ee4ae2a055f47b743ff806dfd41974e94cfc1b..aeb0ca96ebaf8b5aa111bbd71807acb3924cb7d8 100644 (file)
@@ -164,7 +164,9 @@ public class IndexedContainer extends
      */
     @Override
     public Property getContainerProperty(Object itemId, Object propertyId) {
-        if (!containsId(itemId)) {
+        // map lookup more efficient than propertyIds if there are many
+        // properties
+        if (!containsId(itemId) || !types.containsKey(propertyId)) {
             return null;
         }
 
index 20aadfcb8b4fa0cf7587db9693370790d22c135b..971cdb5f6217e24799a92921ea75a7524adb9bcf 100644 (file)
@@ -376,4 +376,12 @@ public class TestIndexedContainer extends AbstractInMemoryContainerTest {
         }
     }
 
+    // test getting non-existing property (#10445)
+    public void testNonExistingProperty() {
+        IndexedContainer ic = new IndexedContainer();
+        String object1 = new String("Obj1");
+        ic.addItem(object1);
+        assertNull(ic.getContainerProperty(object1, "xyz"));
+    }
+
 }