提交 d4a23b81 编写于 作者: J Juergen Hoeller

Properties values get properly converted to generic Map types (fixing 4.x...

Properties values get properly converted to generic Map types (fixing 4.x regression without use of ConversionService)

Issue: SPR-13256
上级 acc8c895
...@@ -521,7 +521,6 @@ class TypeConverterDelegate { ...@@ -521,7 +521,6 @@ class TypeConverterDelegate {
} }
boolean originalAllowed = requiredType.isInstance(original); boolean originalAllowed = requiredType.isInstance(original);
typeDescriptor = typeDescriptor.narrow(original);
TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor(); TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor();
if (elementType == null && originalAllowed && if (elementType == null && originalAllowed &&
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) { !this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
...@@ -603,7 +602,6 @@ class TypeConverterDelegate { ...@@ -603,7 +602,6 @@ class TypeConverterDelegate {
} }
boolean originalAllowed = requiredType.isInstance(original); boolean originalAllowed = requiredType.isInstance(original);
typeDescriptor = typeDescriptor.narrow(original);
TypeDescriptor keyType = typeDescriptor.getMapKeyTypeDescriptor(); TypeDescriptor keyType = typeDescriptor.getMapKeyTypeDescriptor();
TypeDescriptor valueType = typeDescriptor.getMapValueTypeDescriptor(); TypeDescriptor valueType = typeDescriptor.getMapValueTypeDescriptor();
if (keyType == null && valueType == null && originalAllowed && if (keyType == null && valueType == null && originalAllowed &&
......
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,6 +26,7 @@ import java.util.HashSet; ...@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.junit.Test; import org.junit.Test;
...@@ -182,6 +183,18 @@ public class BeanWrapperGenericsTests { ...@@ -182,6 +183,18 @@ public class BeanWrapperGenericsTests {
assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet); assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet);
} }
@Test
public void testGenericMapFromProperties() {
GenericBean<?> gb = new GenericBean<Object>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Properties input = new Properties();
input.setProperty("4", "5");
input.setProperty("6", "7");
bw.setPropertyValue("shortMap", input);
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
@Test @Test
public void testGenericListOfLists() throws MalformedURLException { public void testGenericListOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<String>(); GenericBean<String> gb = new GenericBean<String>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册