Skip to content

Commit

Permalink
Backport #1868 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 4, 2018
1 parent 854e650 commit 9a8cb97
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project: jackson-databind
#1854: NPE deserializing collection with `@JsonCreator` and `ACCEPT_CASE_INSENSITIVE_PROPERTIES`
(reported by rue-jw@github)
#1855: Blacklist for more serialization gadgets (dbcp/tomcat, spring)
#1868: Class name handling for JDK unmodifiable Collection types changed
(reported by Rob W)

2.9.3 (09-Dec-2017)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public Boolean supportsUpdate(DeserializationConfig config) {
/**********************************************************
*/

protected final Object finishBuild(DeserializationContext ctxt, Object builder)
protected Object finishBuild(DeserializationContext ctxt, Object builder)
throws IOException
{
// As per [databind#777], allow returning builder itself
Expand All @@ -183,7 +183,7 @@ protected final Object finishBuild(DeserializationContext ctxt, Object builder)
* Main deserialization method for bean-based objects (POJOs).
*/
@Override
public final Object deserialize(JsonParser p, DeserializationContext ctxt)
public Object deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException
{
// common case first:
Expand Down Expand Up @@ -334,7 +334,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt)
*/
@Override
@SuppressWarnings("resource")
protected final Object _deserializeUsingPropertyBased(final JsonParser p,
protected Object _deserializeUsingPropertyBased(final JsonParser p,
final DeserializationContext ctxt)
throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ private static boolean isJavaUtilCollectionClass(String clz, String type)
if (clz.startsWith("Collections$")) {
// 02-Jan-2017, tatu: As per [databind#1868], may need to leave Unmodifiable variants as is
return (clz.indexOf(type) > 0)
// && !clz.contains("Unmodifiable");
;
&& !clz.contains("Unmodifiable");
}
if (clz.startsWith("Arrays$")) {
return (clz.indexOf(type) > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public void testSingletonCollections() throws Exception
assertEquals(28, result.iterator().next().x);
}

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

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

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

0 comments on commit 9a8cb97

Please sign in to comment.