Skip to content

Commit 35753eb

Browse files
committed
Backported test for fallback for non-resolvable property type
(cherry picked from commit 8570f60)
1 parent 1cb9b9c commit 35753eb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,24 @@ public void testPropertyTypeMismatch() {
15771577
assertEquals(8, bwi.getPropertyValue("object"));
15781578
}
15791579

1580+
@Test
1581+
public void testGenericArraySetter() {
1582+
SkipReaderStub foo = new SkipReaderStub();
1583+
BeanWrapperImpl bwi = new BeanWrapperImpl(foo);
1584+
List<String> values = new LinkedList<String>();
1585+
values.add("1");
1586+
values.add("2");
1587+
values.add("3");
1588+
values.add("4");
1589+
bwi.setPropertyValue("items", values);
1590+
Object[] result = foo.items;
1591+
assertEquals(4, result.length);
1592+
assertEquals("1", result[0]);
1593+
assertEquals("2", result[1]);
1594+
assertEquals("3", result[2]);
1595+
assertEquals("4", result[3]);
1596+
}
1597+
15801598

15811599
static class Spr10115Bean {
15821600

@@ -1991,4 +2009,21 @@ public Integer getObject() {
19912009
}
19922010
}
19932011

2012+
2013+
public static class SkipReaderStub<T> {
2014+
2015+
public T[] items;
2016+
2017+
public SkipReaderStub() {
2018+
}
2019+
2020+
public SkipReaderStub(T... items) {
2021+
this.items = items;
2022+
}
2023+
2024+
public void setItems(T... items) {
2025+
this.items = items;
2026+
}
2027+
}
2028+
19942029
}

0 commit comments

Comments
 (0)