Closed
Description
Describe the bug
I am experiencing issues with the new coercion settings that were released in v2.12.0. I would like to disable coercion between String
and Integer
.
Version information
v2.12.1
To Reproduce
I have class Example (using Lombok annotations):
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Example {
private String type;
}
The ObjectMapper setup:
ObjectMapper mapper = new ObjectMapper();
mapper.coercionConfigFor(LogicalType.Textual)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail);
How I try to deserialize:
Example example = mapper.readValue("{\"type\": 123}", Example.class);
Expected behavior
I expect an exception to be thrown saying that Integer
cannot be converted to String
. But what happens is that example
is successfully created with type
set to "123"
which means there was conversion.
Is there anything wrong I do (maybe with the coercion configuration)?