#1412 - Fix Resource leaks for properties & yaml files etc - Loader

This commit is contained in:
Rob Bygrave
2018-06-10 23:31:16 +12:00
parent 3134dd3165
commit 54eaf561f4
@@ -118,7 +118,9 @@ class Loader {
void loadYaml(String resourcePath, Source source) {
if (yamlLoader != null) {
try {
yamlLoader.load(resource(resourcePath, source));
try (InputStream is = resource(resourcePath, source)) {
yamlLoader.load(is);
}
} catch (Exception e) {
log.warn("Failed to read yml from:" + resourcePath, e);
}
@@ -126,9 +128,14 @@ class Loader {
}
void loadProperties(String resourcePath, Source source) {
InputStream is = resource(resourcePath, source);
if (is != null) {
loadProperties(is);
try {
try (InputStream is = resource(resourcePath, source)) {
if (is != null) {
loadProperties(is);
}
}
} catch (Exception e) {
log.warn("Failed to read properties from:" + resourcePath, e);
}
}