File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
spring-beans/src/test/java/org/springframework/beans
spring-core/src/main/java/org/springframework/core Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change @@ -628,7 +628,7 @@ public Class<?> resolve() {
628628 * Resolve this type to a {@link java.lang.Class}, returning the specified
629629 * {@code fallback} if the type cannot be resolved. This method will consider bounds
630630 * of {@link TypeVariable}s and {@link WildcardType}s if direct resolution fails;
631- * however, bounds of Object.class will be ignored.
631+ * however, bounds of {@code Object.class} will be ignored.
632632 * @param fallback the fallback class to use if resolution fails (may be {@code null})
633633 * @return the resolved {@link Class} or the {@code fallback}
634634 * @see #resolve()
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public TypeDescriptor(Field field) {
105105 public TypeDescriptor (Property property ) {
106106 Assert .notNull (property , "Property must not be null" );
107107 this .resolvableType = ResolvableType .forMethodParameter (property .getMethodParameter ());
108- this .type = this .resolvableType .resolve (Object . class );
108+ this .type = this .resolvableType .resolve (property . getType () );
109109 this .annotations = nullSafeAnnotations (property .getAnnotations ());
110110 }
111111
You can’t perform that action at this time.
0 commit comments