diff options
author | Vassil Zorev <vassil.zorev87@gmail.com> | 2017-10-04 10:31:55 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-04 10:31:55 +0300 |
commit | ad801f706e35a0bb30729d7424d175240b9a5219 (patch) | |
tree | 0f41c9014aa7e7f65defee853f23580d0f734e85 | |
parent | de2c1ce5b7706c3ee355205265d2440667fb6b6f (diff) | |
download | vaadin-framework-ad801f706e35a0bb30729d7424d175240b9a5219.tar.gz vaadin-framework-ad801f706e35a0bb30729d7424d175240b9a5219.zip |
Support null intermediate properties in NestedMethodProperty (#10085)
Ignore null intermediate properties in setValue().
-rw-r--r-- | server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java | 3 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java b/server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java index 014304ce7a..7336e2786e 100644 --- a/server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java +++ b/server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java @@ -245,6 +245,9 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { Object object = instance; for (int i = 0; i < getMethods.size() - 1; i++) { object = getMethods.get(i).invoke(object); + if (object == null) { + return; + } } setMethod.invoke(object, new Object[] { value }); } catch (final InvocationTargetException e) { diff --git a/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java b/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java index e1f59ea896..7fab51e413 100644 --- a/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java +++ b/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java @@ -307,6 +307,12 @@ public class NestedMethodPropertyTest { Address address2 = new Address("Other street", 12345); addressProperty.setValue(address2); Assert.assertEquals("Other street", streetProperty.getValue()); + + Address address3 = null; + addressProperty.setValue(address3); + Assert.assertEquals(null, addressProperty.getValue()); + streetProperty.setValue("Ruukinkatu"); + Assert.assertEquals(null, streetProperty.getValue()); } @Test |