]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes NPE in TreeTable.setContainerDS(null) (#12928)
authorThomas <thomas@vaadin.com>
Fri, 8 Nov 2013 11:59:28 +0000 (13:59 +0200)
committerVaadin Code Review <review@vaadin.com>
Fri, 8 Nov 2013 14:13:18 +0000 (14:13 +0000)
Change-Id: I7f3148e51d216dfe20a11c8a5fd922f43cbc673b

server/src/com/vaadin/ui/TreeTable.java
server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java [new file with mode: 0644]

index e150db9423f8ddbc74337b3f62fce79567d97004..1c13eae8d9cfbc92bfbdc24f8395ecd6e9847351 100644 (file)
@@ -590,11 +590,11 @@ public class TreeTable extends Table implements Hierarchical {
         // does not change component hierarchy during paint
         containerSupportsPartialUpdates = (newDataSource instanceof ItemSetChangeNotifier) && false;
 
-        if (!(newDataSource instanceof Hierarchical)) {
+        if (newDataSource != null && !(newDataSource instanceof Hierarchical)) {
             newDataSource = new ContainerHierarchicalWrapper(newDataSource);
         }
 
-        if (!(newDataSource instanceof Ordered)) {
+        if (newDataSource != null && !(newDataSource instanceof Ordered)) {
             newDataSource = new HierarchicalContainerOrderedWrapper(
                     (Hierarchical) newDataSource);
         }
diff --git a/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java
new file mode 100644 (file)
index 0000000..a3b79a1
--- /dev/null
@@ -0,0 +1,15 @@
+package com.vaadin.tests.server.component.treetable;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.TreeTable;
+
+public class TreeTableSetContainerNull extends TestCase {
+
+    public void testNullContainer() {
+        TreeTable treeTable = new TreeTable();
+
+        // should not cause an exception
+        treeTable.setContainerDataSource(null);
+    }
+}