Skip to content

Commit

Permalink
Fix #3565
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 22, 2022
1 parent 7f4a5b4 commit aac05b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Project: jackson-databind
`PropertyNamingStrategy.UPPER_CAMEL_CASE`
(reported by Jason H)
(fix suggested by gsinghlulu@github)
#3565: `Arrays.asList()` value deserialization has changed from mutable to
immutable in 2.13
(reported by JonasWilms@github)

2.13.3 (14-May-2022)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static JsonDeserializer<?> findForCollection(DeserializationContext ctxt,
if (!clsName.startsWith("java.util.")) {
return null;
}

// 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays`
// need a bit of help...
String localName = _findUtilCollectionsTypeName(clsName);
Expand Down Expand Up @@ -82,8 +81,11 @@ public static JsonDeserializer<?> findForCollection(DeserializationContext ctxt,
if ((localName = _findUtilArrayTypeName(clsName)) != null) {
// Typically ends with "List" but let's just look for it
if (localName.contains("List")) {
// 21-Aug-2022, tatu: [databind#3565] Let's try avoid making "Arrays.asList()"
// unmodifiable tho. Could either match "ArrayList" or just, well,
// default to "any" modifiable List:
return new StdDelegatingDeserializer<Object>(
converter(TYPE_UNMODIFIABLE_LIST, type, List.class));
converter(TYPE_AS_LIST, type, List.class));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ public void testArraysAsList() throws Exception
// contents remain the same
List<String> input = Arrays.asList("a", "bc", "def");
String json = DEFAULT_MAPPER.writeValueAsString(input);
List<?> result = DEFAULT_MAPPER.readValue(json, List.class);
@SuppressWarnings("unchecked")
List<String> result = (List<String>) DEFAULT_MAPPER.readValue(json, List.class);
assertEquals(input, result);
// 21-Aug-2022, tatu: [databind#3565] should try to NOT make it
// unmodifiable
result.set(1, "b");
}

/*
Expand Down

0 comments on commit aac05b7

Please sign in to comment.