Skip to content

Conversion service in Spring 3.1 removes items from Lists in Maps causing Spring Security exceptions [SPR-8364] #13011

@spring-projects-issues

Description

@spring-projects-issues

!!Use pwebb rather than philw opened SPR-8364 and commented

Using the latest snapshot build of Spring 3.1 an IllegalArgumentException is thrown from Spring Security FilterChainProxy.checkContents.

After a bit of hunting I believe that this is due to an error in the converter service. The conversion services is being invoked to convert Map<String,List<Filter>> to Map<Object,Object>, this invokes the MapToMapConverter for the Map and then the CollectionToObjectConverter. The collection to object converter returns the 1st item in the list and discards the rest.

Here is a test case that you can use to verify. This will pass on 3.0.5 and fail on 3.1.0.BUILD-SNAPSHOT

@Test
@SuppressWarnings("unchecked")
public void shouldConvertMaps() throws Exception {
	HashMap<String, List<Integer>> src = new LinkedHashMap<String, List<Integer>>();
	List<Integer> value = new ArrayList<Integer>();
	value.add(1);
	value.add(2);
	value.add(3);
	src.put("k", value);
	GenericConversionService cs = ConversionServiceFactory.createDefaultConversionService();
	Map<Object, Object> converted = cs.convert(src, Map.class);
	assertEquals(value, converted.get("k"));
}

Affects: 3.1 M1

Referenced from: commits 4d6a584, 7430fcd

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions