Skip to content

Commit 28b7509

Browse files
banseok1216fmbenhassine
authored andcommitted
fix: make JsonObjectReader close operations null-safe
Signed-off-by: banseok1216 <bansuk1216@naver.com>
1 parent ed3b2a9 commit 28b7509

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/json/GsonJsonObjectReader.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ public void open(Resource resource) throws Exception {
9797
return null;
9898
}
9999

100-
@SuppressWarnings("DataFlowIssue")
101100
@Override
102101
public void close() throws Exception {
103-
this.inputStream.close();
104-
this.jsonReader.close();
102+
if (inputStream != null) {
103+
inputStream.close();
104+
}
105+
if (jsonReader != null) {
106+
jsonReader.close();
107+
}
105108
}
106109

107110
@SuppressWarnings("DataFlowIssue")

spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/json/JacksonJsonObjectReader.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ public void open(Resource resource) throws Exception {
106106
return null;
107107
}
108108

109-
@SuppressWarnings("DataFlowIssue")
110109
@Override
111110
public void close() throws Exception {
112-
this.inputStream.close();
113-
this.jsonParser.close();
111+
if (inputStream != null) {
112+
inputStream.close();
113+
}
114+
if (jsonParser != null) {
115+
jsonParser.close();
116+
}
114117
}
115118

116119
@SuppressWarnings("DataFlowIssue")

0 commit comments

Comments
 (0)