Plug an `InputStream` resource leak
This commit is contained in:
parent
5751c949e8
commit
4378fbbc12
|
@ -134,28 +134,29 @@ public final class WalaProperties {
|
|||
if (fileName == null) {
|
||||
throw new IllegalArgumentException("null fileName");
|
||||
}
|
||||
final InputStream propertyStream = loader.getResourceAsStream(fileName);
|
||||
if (propertyStream == null) {
|
||||
// create default properties
|
||||
Properties defprop = new Properties();
|
||||
defprop.setProperty(OUTPUT_DIR, "./out");
|
||||
defprop.setProperty(INPUT_DIR, "./in");
|
||||
defprop.setProperty(ECLIPSE_PLUGINS_DIR, "./plugins");
|
||||
defprop.setProperty(WALA_REPORT, "./wala_report.txt");
|
||||
defprop.setProperty(J2EE_DIR, "./j2ee");
|
||||
final String j2selib = guessJavaLib();
|
||||
defprop.setProperty(J2SE_DIR, j2selib);
|
||||
|
||||
return defprop;
|
||||
try (final InputStream propertyStream = loader.getResourceAsStream(fileName)) {
|
||||
if (propertyStream == null) {
|
||||
// create default properties
|
||||
Properties defprop = new Properties();
|
||||
defprop.setProperty(OUTPUT_DIR, "./out");
|
||||
defprop.setProperty(INPUT_DIR, "./in");
|
||||
defprop.setProperty(ECLIPSE_PLUGINS_DIR, "./plugins");
|
||||
defprop.setProperty(WALA_REPORT, "./wala_report.txt");
|
||||
defprop.setProperty(J2EE_DIR, "./j2ee");
|
||||
final String j2selib = guessJavaLib();
|
||||
defprop.setProperty(J2SE_DIR, j2selib);
|
||||
|
||||
return defprop;
|
||||
}
|
||||
Properties result = new Properties();
|
||||
result.load(propertyStream);
|
||||
|
||||
if (!result.containsKey(J2SE_DIR)) {
|
||||
final String j2selib = guessJavaLib();
|
||||
result.setProperty(J2SE_DIR, j2selib);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Properties result = new Properties();
|
||||
result.load(propertyStream);
|
||||
|
||||
if (!result.containsKey(J2SE_DIR)) {
|
||||
final String j2selib = guessJavaLib();
|
||||
result.setProperty(J2SE_DIR, j2selib);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String guessJavaLib() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue