Skip to content

Commit 987a463

Browse files
committed
Add a (failing) test for #1392
1 parent efc6b98 commit 987a463

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.Collections;
4+
import java.util.Set;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
8+
import com.fasterxml.jackson.databind.*;
9+
10+
public class UnmodifiableSetTyping1392Test extends BaseMapTest
11+
{
12+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
13+
abstract static class UnmodifiableSetMixin {
14+
15+
@JsonCreator
16+
public UnmodifiableSetMixin(Set<?> s) {}
17+
}
18+
19+
public void testUnmodifiable() throws Exception
20+
{
21+
ObjectMapper mapper = new ObjectMapper();
22+
Class<?> unmodSetType = Collections.unmodifiableSet(Collections.<String>emptySet()).getClass();
23+
mapper.addMixIn(unmodSetType, UnmodifiableSetMixin.class);
24+
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
25+
26+
final String EXPECTED_JSON = "[\""+unmodSetType.getName()+"\",[]]";
27+
28+
Set<?> foo = mapper.readValue(EXPECTED_JSON, Set.class);
29+
assertTrue(foo.isEmpty());
30+
}
31+
}

0 commit comments

Comments
 (0)