Skip to content

Commit

Permalink
YamlProcessor explicitly closes UnicodeReader
Browse files Browse the repository at this point in the history
Issue: SPR-13173
(cherry picked from commit 26acb48)
  • Loading branch information
jhoeller committed Jun 30, 2015
1 parent a8ac6db commit 3d131c9
Showing 1 changed file with 6 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
package org.springframework.beans.factory.config;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -35,6 +35,7 @@
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.parser.ParserException;
import org.yaml.snakeyaml.reader.UnicodeReader;

import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -155,9 +156,9 @@ private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Loading from YAML: " + resource);
}
InputStream stream = resource.getInputStream();
Reader reader = new UnicodeReader(resource.getInputStream());
try {
for (Object object : yaml.loadAll(stream)) {
for (Object object : yaml.loadAll(reader)) {
if (object != null && process(asMap(object), callback)) {
count++;
if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND) {
Expand All @@ -171,7 +172,7 @@ private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
}
}
finally {
stream.close();
reader.close();
}
}
catch (IOException ex) {
Expand Down

0 comments on commit 3d131c9

Please sign in to comment.