From a15a6bfad805d72d94ae999ae0b7cd14e94f87a2 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 4 Sep 2019 12:52:28 +0200 Subject: [PATCH] Fix object mapper customization in Jackson2ExecutionContextStringSerializer This commit fixes the setter of object mapper to copy the configuration of the custom object mapper provided by the user and "augment" it with the JobParametersModule. Resolves BATCH-2828 --- .../dao/Jackson2ExecutionContextStringSerializer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java index d70ff646c..f20136f42 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2018 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,8 @@ public class Jackson2ExecutionContextStringSerializer implements ExecutionContex public void setObjectMapper(ObjectMapper objectMapper) { Assert.notNull(objectMapper, "ObjectMapper must not be null"); - this.objectMapper = objectMapper; + this.objectMapper = objectMapper.copy(); + this.objectMapper.registerModule(new JobParametersModule()); } public Map deserialize(InputStream in) throws IOException {