Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket to create the ObjectMapper instance. It is not possible to use the builder for spring-messaging and spring-jms since these modules don't have a dependency on spring-web, thus they now just customize the same features: - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled Issue: SPR-12293
This commit is contained in:
@@ -434,12 +434,7 @@ public class Jackson2ObjectMapperBuilder {
|
||||
objectMapper.registerModule(module);
|
||||
}
|
||||
|
||||
if (!this.features.containsKey(MapperFeature.DEFAULT_VIEW_INCLUSION)) {
|
||||
configureFeature(objectMapper, MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
}
|
||||
if (!this.features.containsKey(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) {
|
||||
configureFeature(objectMapper, DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
customizeDefaultFeatures(objectMapper);
|
||||
for (Object feature : this.features.keySet()) {
|
||||
configureFeature(objectMapper, feature, this.features.get(feature));
|
||||
}
|
||||
@@ -475,6 +470,17 @@ public class Jackson2ObjectMapperBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Any change to this method should be also applied to spring-jms and spring-messaging
|
||||
// MappingJackson2MessageConverter default constructors
|
||||
private void customizeDefaultFeatures(ObjectMapper objectMapper) {
|
||||
if (!this.features.containsKey(MapperFeature.DEFAULT_VIEW_INCLUSION)) {
|
||||
configureFeature(objectMapper, MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
}
|
||||
if (!this.features.containsKey(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) {
|
||||
configureFeature(objectMapper, DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> void addSerializers(SimpleModule module) {
|
||||
for (Class<?> type : this.serializers.keySet()) {
|
||||
|
||||
Reference in New Issue
Block a user