Skip to content

Commit

Permalink
fix LOGBACK-1652
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Aug 8, 2022
1 parent fb3032e commit 19999ef
Showing 1 changed file with 3 additions and 6 deletions.
Expand Up @@ -45,12 +45,11 @@ public void handle(ModelInterpretationContext interpretationContext, Model model
if (checkFileAttributeSanity(propertyModel)) {
String file = propertyModel.getFile();
file = interpretationContext.subst(file);
try {
FileInputStream istream = new FileInputStream(file);
try (FileInputStream istream = new FileInputStream(file)) {
loadAndSetProperties(interpretationContext, istream, scope);
} catch (FileNotFoundException e) {
addError("Could not find properties file [" + file + "].");
} catch (IOException e1) {
} catch (IOException|IllegalArgumentException e1) {
addError("Could not read properties file [" + file + "].", e1);
}
} else if (checkResourceAttributeSanity(propertyModel)) {
Expand All @@ -60,8 +59,7 @@ public void handle(ModelInterpretationContext interpretationContext, Model model
if (resourceURL == null) {
addError("Could not find resource [" + resource + "].");
} else {
try {
InputStream istream = resourceURL.openStream();
try ( InputStream istream = resourceURL.openStream();) {
loadAndSetProperties(interpretationContext, istream, scope);
} catch (IOException e) {
addError("Could not read resource file [" + resource + "].", e);
Expand All @@ -85,7 +83,6 @@ public void handle(ModelInterpretationContext interpretationContext, Model model
void loadAndSetProperties(ModelInterpretationContext mic, InputStream istream, Scope scope) throws IOException {
Properties props = new Properties();
props.load(istream);
istream.close();
ModelUtil.setProperties(mic, props, scope);
}

Expand Down

0 comments on commit 19999ef

Please sign in to comment.