Fixed regression with fallback for non-resolvable property type
This commit is contained in:
parent
786e217991
commit
8570f607a7
|
|
@ -1577,6 +1577,24 @@ public final class BeanWrapperTests {
|
|||
assertEquals(8, bwi.getPropertyValue("object"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericArraySetter() {
|
||||
SkipReaderStub foo = new SkipReaderStub();
|
||||
BeanWrapperImpl bwi = new BeanWrapperImpl(foo);
|
||||
List<String> values = new LinkedList<String>();
|
||||
values.add("1");
|
||||
values.add("2");
|
||||
values.add("3");
|
||||
values.add("4");
|
||||
bwi.setPropertyValue("items", values);
|
||||
Object[] result = foo.items;
|
||||
assertEquals(4, result.length);
|
||||
assertEquals("1", result[0]);
|
||||
assertEquals("2", result[1]);
|
||||
assertEquals("3", result[2]);
|
||||
assertEquals("4", result[3]);
|
||||
}
|
||||
|
||||
|
||||
static class Spr10115Bean {
|
||||
|
||||
|
|
@ -1991,4 +2009,21 @@ public final class BeanWrapperTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SkipReaderStub<T> {
|
||||
|
||||
public T[] items;
|
||||
|
||||
public SkipReaderStub() {
|
||||
}
|
||||
|
||||
public SkipReaderStub(T... items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void setItems(T... items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ public final class ResolvableType implements Serializable {
|
|||
* Resolve this type to a {@link java.lang.Class}, returning the specified
|
||||
* {@code fallback} if the type cannot be resolved. This method will consider bounds
|
||||
* of {@link TypeVariable}s and {@link WildcardType}s if direct resolution fails;
|
||||
* however, bounds of Object.class will be ignored.
|
||||
* however, bounds of {@code Object.class} will be ignored.
|
||||
* @param fallback the fallback class to use if resolution fails (may be {@code null})
|
||||
* @return the resolved {@link Class} or the {@code fallback}
|
||||
* @see #resolve()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class TypeDescriptor implements Serializable {
|
|||
public TypeDescriptor(Property property) {
|
||||
Assert.notNull(property, "Property must not be null");
|
||||
this.resolvableType = ResolvableType.forMethodParameter(property.getMethodParameter());
|
||||
this.type = this.resolvableType.resolve(Object.class);
|
||||
this.type = this.resolvableType.resolve(property.getType());
|
||||
this.annotations = nullSafeAnnotations(property.getAnnotations());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue