Skip to content

Commit

Permalink
Close product.conf file
Browse files Browse the repository at this point in the history
  • Loading branch information
bstansberry committed Feb 6, 2013
1 parent 7f9bf3c commit 45f8fd2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion version/src/main/java/org/jboss/as/version/ProductConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package org.jboss.as.version;

import java.io.Closeable;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
Expand Down Expand Up @@ -52,8 +53,9 @@ public ProductConfig(ModuleLoader loader, String home, Map<?, ?> providedPropert
String productVersion = null;
String consoleSlot = null;

FileReader reader = null;
try {
FileReader reader = new FileReader(getProductConf(home));
reader = new FileReader(getProductConf(home));
Properties props = new Properties();
props.load(reader);

Expand All @@ -77,6 +79,8 @@ public ProductConfig(ModuleLoader loader, String home, Map<?, ?> providedPropert
setSystemProperties(props, providedProperties);
} catch (Exception e) {
// Don't care
} finally {
safeClose(reader);
}

name = productName;
Expand Down Expand Up @@ -162,4 +166,11 @@ public Void run() {
AccessController.doPrivileged(action);
}
}

private static void safeClose(Closeable c) {
if (c != null) try {
c.close();
} catch (Throwable ignored) {}
}

}

0 comments on commit 45f8fd2

Please sign in to comment.