From 54eaf561f4bdb3012409765a5f10070667f11373 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 10 Jun 2018 23:31:16 +1200 Subject: [PATCH] #1412 - Fix Resource leaks for properties & yaml files etc - Loader --- .../java/io/ebean/config/properties/Loader.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/ebean/config/properties/Loader.java b/src/main/java/io/ebean/config/properties/Loader.java index b188f9b05..4c0d07443 100644 --- a/src/main/java/io/ebean/config/properties/Loader.java +++ b/src/main/java/io/ebean/config/properties/Loader.java @@ -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); } }