-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
Very similar issue to #1805, but when a property name is specified and MapperFeature.USE_GETTERS_AS_SETTERS
is enabled:
static class Foo {
@JsonProperty(value = "list", access = JsonProperty.Access.READ_ONLY)
List<Long> getList() {
return Collections.unmodifiableList(Arrays.asList());
}
}
Fails with com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.UnsupportedOperationException) (through reference chain: com.fasterxml.jackson.databind.deser.ReadOnlyDeserWithNameTest$Foo["list"]->java.util.Collections$UnmodifiableRandomAccessList[0])
Here's the test:
private final ObjectMapper MAPPER = jsonMapperBuilder().configure(MapperFeature.USE_GETTERS_AS_SETTERS, true).build();
public void testReadOnly() throws Exception
{
String payload = "{\"list\":[1,2,3,4]}";
Foo foo = MAPPER.readValue(payload, Foo.class);
assertTrue("List should be empty", foo.getList().isEmpty());
}
Metadata
Metadata
Assignees
Labels
No labels