Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Force close inputStream

Properties.load(is) doesn't close input stream! Need to do it manually.

Signed-off-by: Dmitry Geraskov <dgeraskov@exadel.com>
  • Loading branch information...
commit 489599c9ca9d0fb6d4220c2684cc090a45b5089e 1 parent 6f3c1e7
Dmitry Geraskov authored koentsje committed
View
14 src/java/org/hibernate/tool/ant/ConfigurationTask.java
@@ -107,8 +107,10 @@ protected void doConfiguration(Configuration configuration) {
protected Properties getProperties() {
if (propertyFile!=null) {
Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ?
+ FileInputStream is = null;
try {
- properties.load(new FileInputStream(propertyFile) );
+ is = new FileInputStream(propertyFile);
+ properties.load(is);
return properties;
}
catch (FileNotFoundException e) {
@@ -116,7 +118,15 @@ protected Properties getProperties() {
}
catch (IOException e) {
throw new BuildException("Problem while loading " + propertyFile,e);
- }
+ }
+ finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
+ }
+ }
} else {
return null;
}
View
10 src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java
@@ -189,7 +189,15 @@ public void testPropertySet() throws FileNotFoundException, IOException {
ge.start();
Properties generated = new Properties();
- generated.load(new FileInputStream(new File(getOutputDir(), "org/hibernate/tool/hbm2x/genericArticle.txt")));
+ FileInputStream is = null;
+ try {
+ is = new FileInputStream(new File(getOutputDir(), "org/hibernate/tool/hbm2x/genericArticle.txt"));
+ generated.load(is);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
assertEquals(generated.getProperty("booleanProperty"), "true");
assertEquals(generated.getProperty("hibernatetool.booleanProperty"), "true");
Please sign in to comment.
Something went wrong with that request. Please try again.