Skip to content

Commit 26acb48

Browse files
committed
YamlProcessor explicitly closes UnicodeReader
Issue: SPR-13173
1 parent 7c94c69 commit 26acb48

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
package org.springframework.beans.factory.config;
1818

1919
import java.io.IOException;
20-
import java.io.InputStream;
20+
import java.io.Reader;
2121
import java.util.AbstractMap;
2222
import java.util.Arrays;
2323
import java.util.Collection;
@@ -35,6 +35,7 @@
3535
import org.yaml.snakeyaml.constructor.Constructor;
3636
import org.yaml.snakeyaml.nodes.MappingNode;
3737
import org.yaml.snakeyaml.parser.ParserException;
38+
import org.yaml.snakeyaml.reader.UnicodeReader;
3839

3940
import org.springframework.core.io.Resource;
4041
import org.springframework.util.Assert;
@@ -155,9 +156,9 @@ private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
155156
if (this.logger.isDebugEnabled()) {
156157
this.logger.debug("Loading from YAML: " + resource);
157158
}
158-
InputStream stream = resource.getInputStream();
159+
Reader reader = new UnicodeReader(resource.getInputStream());
159160
try {
160-
for (Object object : yaml.loadAll(stream)) {
161+
for (Object object : yaml.loadAll(reader)) {
161162
if (object != null && process(asMap(object), callback)) {
162163
count++;
163164
if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND) {
@@ -171,7 +172,7 @@ private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
171172
}
172173
}
173174
finally {
174-
stream.close();
175+
reader.close();
175176
}
176177
}
177178
catch (IOException ex) {

0 commit comments

Comments
 (0)