Closed
Description
Describe the bug
Trying to deserialize the following Java Record throws MismatchedInputException
public record Example(@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) String value) {
}
Same issue happens with at least a regular class and @JsonCreator
constructor
Adding any other fields fixes the issue, even if those fields are also WRITE_ONLY fields.
Stacktrace:
Cannot construct instance of `foo.bar.baz.Example` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{"value": "aaa"}"; line: 1, column: 2]
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `foo.bar.baz.Example` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{"value": "aaa"}"; line: 1, column: 2]
at app//com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at app//com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1739)
at app//com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1364)
at app//com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1424)
at app//com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
at app//com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at app//com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at app//com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
at app//com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
at app//com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740)
Version information
2.15.0
To Reproduce
Using the above record definition with plain ObjectMapper throws the above exception
new ObjectMapper().readValue("{\"value\": \"aaa\"}", Example.class);
Expected behavior
With 2.14.2 value was successfully deserialized.
Metadata
Metadata
Assignees
Labels
No labels