Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergePropertiesIntoMap only works with String [SPR-5669] #10340

Closed
spring-projects-issues opened this issue Apr 12, 2009 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 12, 2009

Nanda Firdausi Muhammad opened SPR-5669 and commented

mergePropertiesIntoMap only works well with String. If the value of the properties is non-String, the returned value is always null.

The problem is that this method is also used for a non-String value, for example in org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.setMappings(Properties)

Check with this test:

   public void testMergePropertiesIntoMap2() {
	Object obj1 = new Object();
	Object obj2 = new Object();
	Object obj3 = new Object();
	Properties defaults = new Properties();
	defaults.put("prop1", obj1);
	Properties props = new Properties(defaults);
	props.put("prop2", obj2);

	Map map = new HashMap();
	map.put("prop3", obj3);

	CollectionUtils.mergePropertiesIntoMap(props, map);
	assertEquals(obj1, map.get("prop1"));
	assertEquals(obj2, map.get("prop2"));
	assertEquals(obj3, map.get("prop3"));
}

Affects: 3.0 M2

Issue Links:

Referenced from: commits 8ee0363

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Strictly speaking, we only use Properties arguments where we actually expect <String,String> pairs... But point taken, we can copy non-String values over as well, which we're doing as of 3.0 M3 now.

Note that we can't copy non-String values from a default Properties object, simply because "java.util.Properties" doesn't allow such access to the default Properties object. In other words, non-String values will only be detected in the given Properties object itself.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants