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() {
1577
1577
assertEquals (8 , bwi .getPropertyValue ("object" ));
1578
1578
}
1579
1579
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
+
1580
1598
1581
1599
static class Spr10115Bean {
1582
1600
@@ -1991,4 +2009,21 @@ public Integer getObject() {
1991
2009
}
1992
2010
}
1993
2011
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
+
1994
2029
}
Original file line number Diff line number Diff line change @@ -628,7 +628,7 @@ public Class<?> resolve() {
628
628
* Resolve this type to a {@link java.lang.Class}, returning the specified
629
629
* {@code fallback} if the type cannot be resolved. This method will consider bounds
630
630
* 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.
632
632
* @param fallback the fallback class to use if resolution fails (may be {@code null})
633
633
* @return the resolved {@link Class} or the {@code fallback}
634
634
* @see #resolve()
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public TypeDescriptor(Field field) {
105
105
public TypeDescriptor (Property property ) {
106
106
Assert .notNull (property , "Property must not be null" );
107
107
this .resolvableType = ResolvableType .forMethodParameter (property .getMethodParameter ());
108
- this .type = this .resolvableType .resolve (Object . class );
108
+ this .type = this .resolvableType .resolve (property . getType () );
109
109
this .annotations = nullSafeAnnotations (property .getAnnotations ());
110
110
}
111
111
You can’t perform that action at this time.
0 commit comments