Skip to content

Commit 8d5242a

Browse files
committed
1 parent 24f5650 commit 8d5242a

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
package org.mybatis.spring;
1717

1818
import java.io.IOException;
19-
import java.io.InputStreamReader;
20-
import java.io.Reader;
2119
import java.util.HashMap;
2220
import java.util.Map;
2321
import java.util.Properties;
@@ -202,25 +200,14 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException, Illegal
202200
Configuration configuration;
203201

204202
if (this.configLocation != null) {
205-
Reader reader = null;
206203
try {
207-
reader = new InputStreamReader(this.configLocation.getInputStream());
208-
// Null environment causes the configuration to use the default.
209-
// This will be overwritten below regardless.
210-
xmlConfigBuilder = new XMLConfigBuilder(reader, null, this.configurationProperties);
204+
xmlConfigBuilder = new XMLConfigBuilder(this.configLocation.getInputStream(), null, this.configurationProperties);
211205
configuration = xmlConfigBuilder.parse();
212206
} catch (IOException ex) {
213207
throw new NestedIOException("Failed to parse config resource: "
214208
+ this.configLocation, ex);
215209
} finally {
216210
ErrorContext.instance().reset();
217-
if (reader != null) {
218-
try {
219-
reader.close();
220-
} catch (IOException ignored) {
221-
// close quietly
222-
}
223-
}
224211
}
225212

226213
if (this.logger.isDebugEnabled()) {
@@ -267,21 +254,13 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException, Illegal
267254
path = mapperLocation.toString();
268255
}
269256

270-
Reader reader = null;
271257
try {
272-
reader = new InputStreamReader(mapperLocation.getInputStream());
273-
XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(reader, configuration, path, sqlFragments);
258+
XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(), configuration, path, sqlFragments);
274259
xmlMapperBuilder.parse();
275260
} catch (Exception e) {
276261
throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);
277262
} finally {
278263
ErrorContext.instance().reset();
279-
if (reader != null) {
280-
try {
281-
reader.close();
282-
} catch (IOException ignored) {
283-
}
284-
}
285264
}
286265

287266
if (this.logger.isDebugEnabled()) {

0 commit comments

Comments
 (0)