Ignore null intermediate properties in setValue(). Forward port of #10085 in 7.7 to the compatibility package.tags/8.2.0.alpha3
@@ -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) { |
@@ -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 |