提交 8c689060 编写于 作者: K Keith Donald

null type descriptor handling

上级 5f8faa3a
......@@ -132,7 +132,7 @@ class TypeConverterDelegate {
// No custom editor but custom ConversionService specified?
ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
if (editor == null && conversionService != null && convertedValue != null) {
if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
TypeDescriptor targetTypeDesc = typeDescriptor;
if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
......
......@@ -70,20 +70,41 @@ import test.beans.TestBean;
public final class BeanWrapperTests {
@Test
@Ignore
public void testNullNestedTypeDescriptor() {
Foo foo = new Foo();
BeanWrapperImpl wrapper = new BeanWrapperImpl(foo);
wrapper.setConversionService(new DefaultConversionService());
wrapper.setAutoGrowNestedPaths(true);
wrapper.setPropertyValue("listOfMaps[0]['luckyNumber']", "9");
assertEquals(9, foo.listOfMaps.get(0).get("luckyNumber"));
assertEquals("9", foo.listOfMaps.get(0).get("luckyNumber"));
}
@Test
public void testNullNestedTypeDescriptor2() {
Foo foo = new Foo();
BeanWrapperImpl wrapper = new BeanWrapperImpl(foo);
wrapper.setConversionService(new DefaultConversionService());
wrapper.setAutoGrowNestedPaths(true);
Map<String, String> map = new HashMap<String, String>();
map.put("favoriteNumber", "9");
wrapper.setPropertyValue("list[0]", map);
assertEquals(map, foo.list.get(0));
}
static class Foo {
private List list;
private List<Map> listOfMaps;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public List<Map> getListOfMaps() {
return listOfMaps;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册