|
16 | 16 | package org.mybatis.spring;
|
17 | 17 |
|
18 | 18 | import java.io.IOException;
|
19 |
| -import java.io.InputStreamReader; |
20 |
| -import java.io.Reader; |
21 | 19 | import java.util.HashMap;
|
22 | 20 | import java.util.Map;
|
23 | 21 | import java.util.Properties;
|
@@ -202,25 +200,14 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException, Illegal
|
202 | 200 | Configuration configuration;
|
203 | 201 |
|
204 | 202 | if (this.configLocation != null) {
|
205 |
| - Reader reader = null; |
206 | 203 | 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); |
211 | 205 | configuration = xmlConfigBuilder.parse();
|
212 | 206 | } catch (IOException ex) {
|
213 | 207 | throw new NestedIOException("Failed to parse config resource: "
|
214 | 208 | + this.configLocation, ex);
|
215 | 209 | } finally {
|
216 | 210 | ErrorContext.instance().reset();
|
217 |
| - if (reader != null) { |
218 |
| - try { |
219 |
| - reader.close(); |
220 |
| - } catch (IOException ignored) { |
221 |
| - // close quietly |
222 |
| - } |
223 |
| - } |
224 | 211 | }
|
225 | 212 |
|
226 | 213 | if (this.logger.isDebugEnabled()) {
|
@@ -267,21 +254,13 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException, Illegal
|
267 | 254 | path = mapperLocation.toString();
|
268 | 255 | }
|
269 | 256 |
|
270 |
| - Reader reader = null; |
271 | 257 | 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); |
274 | 259 | xmlMapperBuilder.parse();
|
275 | 260 | } catch (Exception e) {
|
276 | 261 | throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);
|
277 | 262 | } finally {
|
278 | 263 | ErrorContext.instance().reset();
|
279 |
| - if (reader != null) { |
280 |
| - try { |
281 |
| - reader.close(); |
282 |
| - } catch (IOException ignored) { |
283 |
| - } |
284 |
| - } |
285 | 264 | }
|
286 | 265 |
|
287 | 266 | if (this.logger.isDebugEnabled()) {
|
|
0 commit comments