Commit 66f6a822 authored by Guus der Kinderen's avatar Guus der Kinderen Committed by Christian Schudt

Resources should be closed where they are opened.

Problems are inevatible when a resource is opened, passed around
and closed by a different method. This can improved upon easily.
parent 60c8f3d2
...@@ -113,8 +113,9 @@ public class XMLProperties { ...@@ -113,8 +113,9 @@ public class XMLProperties {
* @throws IOException if an exception occurs when reading the stream. * @throws IOException if an exception occurs when reading the stream.
*/ */
public XMLProperties(InputStream in) throws IOException { public XMLProperties(InputStream in) throws IOException {
Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); try (Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"))) {
buildDoc(reader); buildDoc(reader);
}
} }
/** /**
...@@ -153,8 +154,9 @@ public class XMLProperties { ...@@ -153,8 +154,9 @@ public class XMLProperties {
throw new IOException("XML properties file must be writable: " + file.getName()); throw new IOException("XML properties file must be writable: " + file.getName());
} }
FileReader reader = new FileReader(file); try (FileReader reader = new FileReader(file)) {
buildDoc(reader); buildDoc(reader);
}
} }
/** /**
...@@ -729,11 +731,6 @@ public class XMLProperties { ...@@ -729,11 +731,6 @@ public class XMLProperties {
Log.error("Error reading XML properties", e); Log.error("Error reading XML properties", e);
throw new IOException(e.getMessage()); throw new IOException(e.getMessage());
} }
finally {
if (in != null) {
in.close();
}
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment