Skip to content

Commit

Permalink
Adding a few try-with-ressources in PropertiesManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacchella committed Dec 14, 2018
1 parent efc05cd commit 5ab1ad0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions jrds-core/src/main/java/jrds/PropertiesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.IOUtils;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -120,8 +119,7 @@ public Map<String, String> subKey(String prefix) {
}

public void join(URL url) {
try {
InputStream inputstream = url.openStream();
try (InputStream inputstream = url.openStream()){
load(inputstream);
inputstream.close();
} catch (IOException ex) {
Expand All @@ -135,14 +133,10 @@ public void join(Properties moreProperties) {

public void join(File propFile) {
logger.debug("Using propertie file " + propFile.getAbsolutePath());
InputStream inputstream = null;
try {
inputstream = new FileInputStream(propFile);
try (InputStream inputstream = new FileInputStream(propFile)) {
load(inputstream);
} catch (IOException ex) {
logger.warn("Invalid properties file " + propFile.getAbsolutePath() + ": " + ex.getLocalizedMessage());
} finally {
IOUtils.closeQuietly(inputstream);
}
}

Expand Down

0 comments on commit 5ab1ad0

Please sign in to comment.