diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectMarshaller.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectMarshaller.java index 501afe138..c4c982d62 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectMarshaller.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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. @@ -28,14 +28,14 @@ import com.google.gson.Gson; */ public class GsonJsonObjectMarshaller implements JsonObjectMarshaller { - private Gson gson = new Gson(); + private Gson gson; public GsonJsonObjectMarshaller() { - this.gson=new Gson(); + this(new Gson()); } public GsonJsonObjectMarshaller(Gson gson) { - this.gson=gson; + this.gson = gson; } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java index 128121e16..da493a1a1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2021 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. @@ -55,8 +55,7 @@ public class GsonJsonObjectReader implements JsonObjectReader { * @param itemType the target item type */ public GsonJsonObjectReader(Class itemType) { - this.mapper = new Gson(); - this.itemType = itemType; + this(new Gson(), itemType); } public GsonJsonObjectReader(Gson mapper, Class itemType) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectMarshaller.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectMarshaller.java index 535bd4e7f..dab06b215 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectMarshaller.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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. @@ -34,11 +34,11 @@ public class JacksonJsonObjectMarshaller implements JsonObjectMarshaller { private ObjectMapper objectMapper; public JacksonJsonObjectMarshaller() { - this.objectMapper = new ObjectMapper(); + this(new ObjectMapper()); } public JacksonJsonObjectMarshaller(ObjectMapper objectMapper) { - this.objectMapper=objectMapper; + this.objectMapper = objectMapper; } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java index bffbf5da2..141446f6c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2021 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. @@ -52,13 +52,12 @@ public class JacksonJsonObjectReader implements JsonObjectReader { * @param itemType the target item type */ public JacksonJsonObjectReader(Class itemType) { - this.mapper=new ObjectMapper(); - this.itemType = itemType; + this(new ObjectMapper(), itemType); } public JacksonJsonObjectReader(ObjectMapper mapper, Class itemType) { - this.mapper= mapper; - this.itemType=itemType; + this.mapper = mapper; + this.itemType = itemType; } /**