Skip to content

Commit 9a8cb97

Browse files
committed
Backport #1868 fix
1 parent 854e650 commit 9a8cb97

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
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/deser/BuilderBasedDeserializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Boolean supportsUpdate(DeserializationConfig config) {
165165
/**********************************************************
166166
*/
167167

168-
protected final Object finishBuild(DeserializationContext ctxt, Object builder)
168+
protected Object finishBuild(DeserializationContext ctxt, Object builder)
169169
throws IOException
170170
{
171171
// As per [databind#777], allow returning builder itself
@@ -183,7 +183,7 @@ protected final Object finishBuild(DeserializationContext ctxt, Object builder)
183183
* Main deserialization method for bean-based objects (POJOs).
184184
*/
185185
@Override
186-
public final Object deserialize(JsonParser p, DeserializationContext ctxt)
186+
public Object deserialize(JsonParser p, DeserializationContext ctxt)
187187
throws IOException
188188
{
189189
// common case first:
@@ -334,7 +334,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt)
334334
*/
335335
@Override
336336
@SuppressWarnings("resource")
337-
protected final Object _deserializeUsingPropertyBased(final JsonParser p,
337+
protected Object _deserializeUsingPropertyBased(final JsonParser p,
338338
final DeserializationContext ctxt)
339339
throws IOException
340340
{

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public void testSingletonCollections() throws Exception
4646
assertEquals(28, result.iterator().next().x);
4747
}
4848

49-
// [databind#1868]: Not sure if this should or should not pass...
50-
/*
49+
// [databind#1868]: Verify class name serialized as is
5150
public void testUnmodifiableSet() throws Exception
5251
{
5352
ObjectMapper mapper = new ObjectMapper();
@@ -58,10 +57,15 @@ public void testUnmodifiableSet() throws Exception
5857

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

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

0 commit comments

Comments
 (0)