We have a Spring based application and we have defined a singleton bean for Jackson ObjectMapper class.
@Bean(name = "jacksonObjectMapper")
public ObjectMapper createObjectMapper() {
return new ObjectMapper();
}
We have a use case to write a generic JSON Serializer/Deserializer which we wrote in following way:
public <T, U> T deserialize(final String inputJsonString, final Class<T> targetType, final Class<U> targetParameterType) throws JsonProcessingException, IOException {
return objectMapper
.reader(objectMapper.getTypeFactory().constructParametricType(targetType, targetParameterType))
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.readValue(inputJsonString);
}
Here I am using ObjectReader instead of ObjectMapper itself and changing some configurations on ObjectReader (e.g. .without(...)). My question is, will such configuration changes impact other threads which may be using the same ObjectMapper instance to do something else (may be simply deserializing or serializing)?
Could someone help me understand the details and guide me?
My apologies if I haven't explained the question clearly; please let me know and I can provide further details.