Skip to content

Commit 698fd30

Browse files
committed
Fixed #1868
1 parent ebb726a commit 698fd30

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

release-notes/CREDITS-2.x

+4
Original file line numberDiff line numberDiff line change
@@ -707,3 +707,7 @@ Tim Bartley (tbartley@github)
707707
* Reported, suggested fix for #1705: Non-generic interface method hides type resolution info
708708
from generic base class
709709
(2.9.1)
710+
711+
Rob Winch (rwinch@github)
712+
* Reported #1868: Class name handling for JDK unmodifiable Collection types changed
713+
(2.9.4)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Project: jackson-databind
1010
#1854: NPE deserializing collection with `@JsonCreator` and `ACCEPT_CASE_INSENSITIVE_PROPERTIES`
1111
(reported by rue-jw@github)
1212
#1855: Blacklist for more serialization gadgets (dbcp/tomcat, spring)
13+
#1868: Class name handling for JDK unmodifiable Collection types changed
14+
(reported by Rob W)
1315

1416
2.9.3 (09-Dec-2017)
1517

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ private static boolean isJavaUtilCollectionClass(String clz, String type)
134134
if (clz.startsWith("Collections$")) {
135135
// 02-Jan-2017, tatu: As per [databind#1868], may need to leave Unmodifiable variants as is
136136
return (clz.indexOf(type) > 0)
137-
// && !clz.contains("Unmodifiable");
138-
;
137+
&& !clz.contains("Unmodifiable");
139138
}
140139
if (clz.startsWith("Arrays$")) {
141140
return (clz.indexOf(type) > 0);

src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKCollectionsDeserTest.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.*;
44

5+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
56
import com.fasterxml.jackson.core.type.TypeReference;
67

78
import com.fasterxml.jackson.databind.*;
@@ -44,8 +45,7 @@ public void testSingletonCollections() throws Exception
4445
assertEquals(28, result.iterator().next().x);
4546
}
4647

47-
// [databind#1868]: Not sure if this should or should not pass...
48-
/*
48+
// [databind#1868]: Verify class name serialized as is
4949
public void testUnmodifiableSet() throws Exception
5050
{
5151
ObjectMapper mapper = new ObjectMapper();
@@ -56,10 +56,16 @@ public void testUnmodifiableSet() throws Exception
5656

5757
assertEquals("[\"java.util.Collections$UnmodifiableSet\",[\"a\"]]", json);
5858

59-
// and back...
59+
// 04-Jan-2018, tatu: Alas, no way to make this actually work well, at this point.
60+
// In theory could jiggle things back on deser, using one of two ways:
61+
//
62+
// 1) Do mapping to regular Set/List types (abstract type mapping): would work, but get rid of immutability
63+
// 2) Have actually separate deserializer OR ValueInstantiator
64+
65+
/*
6066
Set<String> result = mapper.readValue(json, Set.class);
6167
assertNotNull(result);
6268
assertEquals(1, result.size());
69+
*/
6370
}
64-
*/
6571
}

src/test/java/perf/ManualReadPerfUntyped.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static void main(String[] args) throws Exception
2121
boolean doIntern = true;
2222

2323
JsonFactory f = JsonFactory.builder()
24-
.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
25-
.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
24+
.set(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
25+
.set(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
2626
.build();
2727

2828
ObjectMapper m = new ObjectMapper(f);

src/test/java/perf/ManualReadPerfUntypedReader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public static void main(String[] args) throws Exception
2222
boolean doIntern = true;
2323

2424
JsonFactory f = JsonFactory.builder()
25-
.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
26-
.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
25+
.set(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
26+
.set(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
2727
.build();
2828
ObjectMapper m = new ObjectMapper(f);
2929
Object input1 = m.readValue(data, Object.class);

src/test/java/perf/ManualReadPerfUntypedStream.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static void main(String[] args) throws Exception
2121

2222
boolean doIntern = true;
2323
JsonFactory f = JsonFactory.builder()
24-
.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
25-
.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
24+
.set(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern)
25+
.set(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern)
2626
.build();
2727
ObjectMapper m = new ObjectMapper(f);
2828
Object input1 = m.readValue(data, Object.class);

0 commit comments

Comments
 (0)