diff --git a/hitool-core/src/test/java/hitool/core/beanutils/BeanPropertyIndexedConversionTest.java b/hitool-core/src/test/java/hitool/core/beanutils/BeanPropertyIndexedConversionTest.java index cdc13a0..25b9b54 100644 --- a/hitool-core/src/test/java/hitool/core/beanutils/BeanPropertyIndexedConversionTest.java +++ b/hitool-core/src/test/java/hitool/core/beanutils/BeanPropertyIndexedConversionTest.java @@ -35,6 +35,18 @@ public void initializesNullArraysAndPreservesStringNulls() { assertNull(root.getChild().getLabels()[0]); } + @Test + public void retainsBeanUtilsConversionForMalformedAndNullNumericValues() { + Root root = new Root(); + root.setChild(new Child()); + root.getChild().setNumbers(new int[] {5, 9}); + // BeanUtils 1.11.0 converts malformed or null primitive values to zero. + BeanPropertyUtils.setProperty(root, "child.numbers[0]", "not-a-number", true); + assertArrayEquals(new int[] {0, 9}, root.getChild().getNumbers()); + BeanPropertyUtils.setProperty(root, "child.numbers[1]", null, true); + assertArrayEquals(new int[] {0, 0}, root.getChild().getNumbers()); + } + @Test public void invalidIndexDoesNotChangeExistingElements() { Root root = new Root();