Skip to content

Commit 17243c1

Browse files
committed
Remove usage of deprecated APIs from Jackson
1 parent 69704ac commit 17243c1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.fasterxml.jackson.databind.ObjectMapper;
4444
import com.fasterxml.jackson.databind.cfg.MapperConfig;
4545
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
46+
import com.fasterxml.jackson.databind.json.JsonMapper;
4647
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
4748
import com.fasterxml.jackson.databind.jsontype.NamedType;
4849
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
@@ -114,12 +115,13 @@ public class Jackson2ExecutionContextStringSerializer implements ExecutionContex
114115
* default set of trusted classes.
115116
*/
116117
public Jackson2ExecutionContextStringSerializer(String... trustedClassNames) {
117-
this.objectMapper = new ObjectMapper();
118-
this.objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
119-
this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
120-
this.objectMapper.configure(MapperFeature.BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES, true);
121-
this.objectMapper.setDefaultTyping(createTrustedDefaultTyping(trustedClassNames));
122-
this.objectMapper.registerModule(new JobParametersModule());
118+
this.objectMapper = JsonMapper.builder()
119+
.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false)
120+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
121+
.configure(MapperFeature.BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES, true)
122+
.setDefaultTyping(createTrustedDefaultTyping(trustedClassNames))
123+
.addModule(new JobParametersModule())
124+
.build();
123125
}
124126

125127
public void setObjectMapper(ObjectMapper objectMapper) {

0 commit comments

Comments
 (0)