Skip to content

Class name handling for JDK unmodifiable Collection types changed in 2.9.3, 2.8.11 #1868

@rwinch

Description

@rwinch

It appears that the default typing in jackson-databind-2.8.11 and jackson-databind-2.9.3 is inconsistent with prior versions. For example, the following test works in 2.9.2 and fails in 2.9.3 and 2.9.4-SNAPSHOT. The test also works in 2.8.10 but fails in 2.8.11

@Test
public void passesWith2dot9dot2AndFailsWith2dot9dot3() throws Exception {
	ObjectMapper mapper = new ObjectMapper();
	mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);

	Set<String> theSet = Collections.unmodifiableSet(Collections.singleton("a"));

	String actualJson = mapper.writeValueAsString(theSet);

	assertEquals("[\"java.util.Collections$UnmodifiableSet\",[\"a\"]]", actualJson);
}

The failure is:

org.junit.ComparisonFailure: 
Expected :["java.util.Collections$UnmodifiableSet",["a"]]
Actual   :["java.util.HashSet",["a"]]

This issue appears to be related to the build failures in spring-projects/spring-security#4918

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions