/hg/icedtea-web: Close streams after we're finished using them.
dlila at icedtea.classpath.org
dlila at icedtea.classpath.org
Tue Mar 8 11:45:30 PST 2011
changeset d558a9a44d5b in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=d558a9a44d5b
author: Denis Lila <dlila at redhat.com>
date: Tue Mar 08 14:48:34 2011 -0500
Close streams after we're finished using them.
diffstat:
ChangeLog | 13 +
netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java | 43 +++--
netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java | 74 +++++----
netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java | 24 ++-
netx/net/sourceforge/jnlp/security/CertWarningPane.java | 6 +-
netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java | 6 +-
6 files changed, 101 insertions(+), 65 deletions(-)
diffs (247 lines):
diff -r 6dd840d6a04d -r d558a9a44d5b ChangeLog
--- a/ChangeLog Tue Mar 08 10:11:28 2011 -0500
+++ b/ChangeLog Tue Mar 08 14:48:34 2011 -0500
@@ -1,3 +1,16 @@
+2011-03-08 Denis Lila <dlila at redhat.com>
+
+ * netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java
+ (find): Close input stream.
+ * netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
+ (parse): Close input stream.
+ * netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
+ (getPacContents, getHelperFunctionContents): Close input stream.
+ * netx/net/sourceforge/jnlp/security/CertWarningPane.java
+ (CheckBoxListener.actionPerformed): Close output stream.
+ * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
+ (ImportButtonListener.actionPerformed): Close output stream.
+
2011-03-08 Andrew Su <asu at redhat.com>
* netx/net/sourceforge/jnlp/util/PropertiesFile.java:
diff -r 6dd840d6a04d -r d558a9a44d5b netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java
--- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java Tue Mar 08 10:11:28 2011 -0500
+++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java Tue Mar 08 14:48:34 2011 -0500
@@ -85,31 +85,34 @@
*/
// find the section with an entry Default=1
- while (true) {
- String line = reader.readLine();
- if (line == null) {
- break;
- }
-
- line = line.trim();
- if (line.startsWith("[") && line.endsWith("]")) {
- if (foundDefaultSection) {
+ try {
+ while (true) {
+ String line = reader.readLine();
+ if (line == null) {
break;
}
- // new section
- linesInSection = new ArrayList<String>();
- } else {
- linesInSection.add(line);
- int equalSignPos = line.indexOf('=');
- if (equalSignPos > 0) {
- String key = line.substring(0, equalSignPos).trim();
- String value = line.substring(equalSignPos+1).trim();
- if (key.toLowerCase().equals("default") && value.equals("1")) {
- foundDefaultSection = true;
+
+ line = line.trim();
+ if (line.startsWith("[") && line.endsWith("]")) {
+ if (foundDefaultSection) {
+ break;
+ }
+ // new section
+ linesInSection = new ArrayList<String>();
+ } else {
+ linesInSection.add(line);
+ int equalSignPos = line.indexOf('=');
+ if (equalSignPos > 0) {
+ String key = line.substring(0, equalSignPos).trim();
+ String value = line.substring(equalSignPos+1).trim();
+ if (key.toLowerCase().equals("default") && value.equals("1")) {
+ foundDefaultSection = true;
+ }
}
}
}
-
+ } finally {
+ reader.close();
}
if (!foundDefaultSection) {
diff -r 6dd840d6a04d -r d558a9a44d5b netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
--- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java Tue Mar 08 10:11:28 2011 -0500
+++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java Tue Mar 08 14:48:34 2011 -0500
@@ -87,52 +87,56 @@
BufferedReader reader = new BufferedReader(new FileReader(prefsFile));
- while (true) {
- String line = reader.readLine();
- // end of stream
- if (line == null) {
- break;
- }
+ try {
+ while (true) {
+ String line = reader.readLine();
+ // end of stream
+ if (line == null) {
+ break;
+ }
- line = line.trim();
- if (line.startsWith("user_pref")) {
+ line = line.trim();
+ if (line.startsWith("user_pref")) {
- /*
- * each line is of the form: user_pref("key",value); where value
- * can be a string in double quotes or an integer or float or
- * boolean
- */
+ /*
+ * each line is of the form: user_pref("key",value); where value
+ * can be a string in double quotes or an integer or float or
+ * boolean
+ */
- boolean foundKey = false;
- boolean foundValue = false;
+ boolean foundKey = false;
+ boolean foundValue = false;
- // extract everything inside user_pref( and );
- String pref = line.substring("user_pref(".length(), line.length() - 2);
- // key and value are separated by a ,
- int firstCommaPos = pref.indexOf(',');
- if (firstCommaPos >= 1) {
- String key = pref.substring(0, firstCommaPos).trim();
- if (key.startsWith("\"") && key.endsWith("\"")) {
- key = key.substring(1, key.length() - 1);
- if (key.trim().length() > 0) {
- foundKey = true;
+ // extract everything inside user_pref( and );
+ String pref = line.substring("user_pref(".length(), line.length() - 2);
+ // key and value are separated by a ,
+ int firstCommaPos = pref.indexOf(',');
+ if (firstCommaPos >= 1) {
+ String key = pref.substring(0, firstCommaPos).trim();
+ if (key.startsWith("\"") && key.endsWith("\"")) {
+ key = key.substring(1, key.length() - 1);
+ if (key.trim().length() > 0) {
+ foundKey = true;
+ }
}
- }
- if (pref.length() > firstCommaPos + 1) {
- String value = pref.substring(firstCommaPos + 1).trim();
- if (value.startsWith("\"") && value.endsWith("\"")) {
- value = value.substring(1, value.length() - 1).trim();
- }
- foundValue = true;
+ if (pref.length() > firstCommaPos + 1) {
+ String value = pref.substring(firstCommaPos + 1).trim();
+ if (value.startsWith("\"") && value.endsWith("\"")) {
+ value = value.substring(1, value.length() - 1).trim();
+ }
+ foundValue = true;
- if (foundKey && foundValue) {
- // System.out.println("added (\"" + key + "\", \"" + value + "\")");
- prefs.put(key, value);
+ if (foundKey && foundValue) {
+ // System.out.println("added (\"" + key + "\", \"" + value + "\")");
+ prefs.put(key, value);
+ }
}
}
}
}
+ } finally {
+ reader.close();
}
if (JNLPRuntime.isDebug()) {
System.out.println("Read " + prefs.size() + " entries from Firefox's preferences");
diff -r 6dd840d6a04d -r d558a9a44d5b netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
--- a/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java Tue Mar 08 10:11:28 2011 -0500
+++ b/netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java Tue Mar 08 14:48:34 2011 -0500
@@ -140,11 +140,15 @@
StringBuilder contents = null;
try {
String line = null;
+ contents = new StringBuilder();
BufferedReader pacReader = new BufferedReader(new InputStreamReader(pacUrl.openStream()));
- contents = new StringBuilder();
- while ((line = pacReader.readLine()) != null) {
- // System.out.println(line);
- contents = contents.append(line).append("\n");
+ try {
+ while ((line = pacReader.readLine()) != null) {
+ // System.out.println(line);
+ contents = contents.append(line).append("\n");
+ }
+ } finally {
+ pacReader.close();
}
} catch (IOException e) {
contents = null;
@@ -167,10 +171,14 @@
}
InputStream in = cl.getResourceAsStream("net/sourceforge/jnlp/runtime/pac-funcs.js");
BufferedReader pacFuncsReader = new BufferedReader(new InputStreamReader(in));
- contents = new StringBuilder();
- while ((line = pacFuncsReader.readLine()) != null) {
- // System.out.println(line);
- contents = contents.append(line).append("\n");
+ try {
+ contents = new StringBuilder();
+ while ((line = pacFuncsReader.readLine()) != null) {
+ // System.out.println(line);
+ contents = contents.append(line).append("\n");
+ }
+ } finally {
+ pacFuncsReader.close();
}
} catch (IOException e) {
e.printStackTrace();
diff -r 6dd840d6a04d -r d558a9a44d5b netx/net/sourceforge/jnlp/security/CertWarningPane.java
--- a/netx/net/sourceforge/jnlp/security/CertWarningPane.java Tue Mar 08 10:11:28 2011 -0500
+++ b/netx/net/sourceforge/jnlp/security/CertWarningPane.java Tue Mar 08 14:48:34 2011 -0500
@@ -252,7 +252,11 @@
}
OutputStream os = new FileOutputStream(keyStoreFile);
- ks.store(os, KeyStores.getPassword());
+ try {
+ ks.store(os, KeyStores.getPassword());
+ } finally {
+ os.close();
+ }
if (JNLPRuntime.isDebug()) {
System.out.println("certificate is now permanently trusted");
}
diff -r 6dd840d6a04d -r d558a9a44d5b netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
--- a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java Tue Mar 08 10:11:28 2011 -0500
+++ b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java Tue Mar 08 14:48:34 2011 -0500
@@ -369,7 +369,11 @@
}
OutputStream os = new FileOutputStream(keyStoreFile);
- ks.store(os, KeyStores.getPassword());
+ try {
+ ks.store(os, KeyStores.getPassword());
+ } finally {
+ os.close();
+ }
repopulateTables();
} catch (Exception ex) {
// TODO: handle exception
More information about the distro-pkg-dev
mailing list