]> source.dussan.org Git - vaadin-framework.git/commitdiff
Support null intermediate properties in NestedMethodProperty (#10085)
authorVassil Zorev <vassil.zorev87@gmail.com>
Wed, 4 Oct 2017 07:31:55 +0000 (10:31 +0300)
committerHenri Sara <henri.sara@gmail.com>
Wed, 4 Oct 2017 07:31:55 +0000 (10:31 +0300)
Ignore null intermediate properties in setValue().

server/src/main/java/com/vaadin/data/util/NestedMethodProperty.java
server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java

index 014304ce7a0d5cd47fa3757b103c053175819828..7336e2786ec9b83ed17bc1ed66284a0e0c6a0535 100644 (file)
@@ -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) {
index e1f59ea8961b764af3a8be5b85892cea2aa5bf6f..7fab51e4132b70003399999befe269acf7217b4c 100644 (file)
@@ -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