From 8efc38528e6eaf5496dea2db514d3ba9c6df190d Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 8 Nov 2013 13:59:28 +0200 Subject: [PATCH] Fixes NPE in TreeTable.setContainerDS(null) (#12928) Change-Id: I7f3148e51d216dfe20a11c8a5fd922f43cbc673b --- server/src/com/vaadin/ui/TreeTable.java | 4 ++-- .../treetable/TreeTableSetContainerNull.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java index e150db9423..1c13eae8d9 100644 --- a/server/src/com/vaadin/ui/TreeTable.java +++ b/server/src/com/vaadin/ui/TreeTable.java @@ -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 index 0000000000..a3b79a14f0 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java @@ -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); + } +} -- 2.39.5