Skip to content

Commit 2ec79d3

Browse files
author
cszxyang
committed
avoid generating NullPointerException while closing IO
1 parent 774a52d commit 2ec79d3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/apache/ibatis/session/SqlSessionFactoryBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public SqlSessionFactory build(Reader reader, String environment, Properties pro
5353
} finally {
5454
ErrorContext.instance().reset();
5555
try {
56-
reader.close();
56+
if (reader != null) {
57+
reader.close();
58+
}
5759
} catch (IOException e) {
5860
// Intentionally ignore. Prefer previous error.
5961
}
@@ -81,7 +83,9 @@ public SqlSessionFactory build(InputStream inputStream, String environment, Prop
8183
} finally {
8284
ErrorContext.instance().reset();
8385
try {
84-
inputStream.close();
86+
if (inputStream != null) {
87+
inputStream.close();
88+
}
8589
} catch (IOException e) {
8690
// Intentionally ignore. Prefer previous error.
8791
}

0 commit comments

Comments
 (0)