/hg/icedtea-web: Close streams after opening them.
asu at icedtea.classpath.org
asu at icedtea.classpath.org
Tue Mar 8 07:12:09 PST 2011
changeset 6dd840d6a04d in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=6dd840d6a04d
author: Andrew Su <asu at redhat.com>
date: Tue Mar 08 10:11:28 2011 -0500
Close streams after opening them.
diffstat:
ChangeLog | 6 +++++
netx/net/sourceforge/jnlp/util/PropertiesFile.java | 24 ++++++++++++++-------
2 files changed, 22 insertions(+), 8 deletions(-)
diffs (68 lines):
diff -r 9a504cfa4f64 -r 6dd840d6a04d ChangeLog
--- a/ChangeLog Tue Mar 08 09:43:59 2011 -0500
+++ b/ChangeLog Tue Mar 08 10:11:28 2011 -0500
@@ -1,3 +1,9 @@
+2011-03-08 Andrew Su <asu at redhat.com>
+
+ * netx/net/sourceforge/jnlp/util/PropertiesFile.java:
+ (load): Closed streams after opening them.
+ (store): Likewise.
+
2011-03-08 Denis Lila <dlila at redhat.com>
* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
diff -r 9a504cfa4f64 -r 6dd840d6a04d netx/net/sourceforge/jnlp/util/PropertiesFile.java
--- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java Tue Mar 08 09:43:59 2011 -0500
+++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java Tue Mar 08 10:11:28 2011 -0500
@@ -25,8 +25,6 @@
* file when the first property is requested, but the save method
* must be called before changes are saved to the file.<p>
*
- * This class does not report IO exceptions.<p>
- *
* @author <a href="mailto:jmaxwell at users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author
* @version $Revision: 1.4 $
*/
@@ -110,14 +108,19 @@
public void load() {
loaded = true;
+ InputStream s = null;
try {
if (!file.exists())
return;
- InputStream s = new FileInputStream(file);
- load(s);
+ try {
+ s = new FileInputStream(file);
+ load(s);
+ } finally {
+ if (s != null) s.close();
+ }
} catch (IOException ex) {
- // eat
+ ex.printStackTrace();
}
}
@@ -128,11 +131,16 @@
if (!loaded)
return; // nothing could have changed so save unnecessary load/save
+ OutputStream s = null;
try {
- OutputStream s = new FileOutputStream(file);
- store(s, header);
+ try {
+ s = new FileOutputStream(file);
+ store(s, header);
+ } finally {
+ if (s != null) s.close();
+ }
} catch (IOException ex) {
- // eat
+ ex.printStackTrace();
}
}
More information about the distro-pkg-dev
mailing list