]> source.dussan.org Git - vaadin-framework.git/commitdiff
Support null intermediate properties in NestedMethodProperty (#10134)
authorOlli Tietäväinen <ollit@vaadin.com>
Wed, 4 Oct 2017 10:18:38 +0000 (13:18 +0300)
committerHenri Sara <henri.sara@gmail.com>
Wed, 4 Oct 2017 10:18:38 +0000 (13:18 +0300)
Ignore null intermediate properties in setValue().

Forward port of #10085 in 7.7 to the compatibility package.

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

index 4228f04dcba172bac83fda592ad0b3e33ac89217..e9a24d040e25d83caf19a65af1e085972a6545fb 100644 (file)
@@ -253,6 +253,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 96065ae199cb1fccf8721677cf80b7d19cbcf348..82e3fbb86a1168beac19b583a5f26a5cda9ad143 100644 (file)
@@ -308,6 +308,12 @@ public class NestedMethodPropertyTest {
         Address address2 = new Address("Other street", 12345);
         addressProperty.setValue(address2);
         assertEquals("Other street", streetProperty.getValue());
+
+        Address address3 = null;
+        addressProperty.setValue(address3);
+        assertEquals(null, addressProperty.getValue());
+        streetProperty.setValue("Ruukinkatu");
+        assertEquals(null, streetProperty.getValue());
     }
 
     @Test