aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-03-05 16:35:40 -0500
committerAdam Domurad <[email protected]>2013-03-05 16:35:40 -0500
commit7d11da0879ecfe284a5413c0a223fecf67e28deb (patch)
treecca352c15da1bf39ed3971e3e401ada49bd38139 /netx/net/sourceforge
parentb1bf883b2c2f9fe7287509beaa830a78513e0af6 (diff)
Move stream closing utility in JNLPClassLoader to StreamUtils
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java23
-rw-r--r--netx/net/sourceforge/jnlp/util/StreamUtils.java18
2 files changed, 22 insertions, 19 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index 05f7622..273a46a 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -89,6 +89,7 @@ import net.sourceforge.jnlp.security.PluginAppVerifier;
import net.sourceforge.jnlp.security.SecurityDialogs;
import net.sourceforge.jnlp.tools.JarCertVerifier;
import net.sourceforge.jnlp.util.FileUtils;
+import net.sourceforge.jnlp.util.StreamUtils;
import sun.misc.JarIndex;
/**
@@ -1022,30 +1023,16 @@ public class JNLPClassLoader extends URLClassLoader {
} finally {
//Close all streams
- closeStream(inStream);
- closeStream(inputReader);
- closeStream(fr);
- closeStream(jnlpReader);
+ StreamUtils.closeSilently(inStream);
+ StreamUtils.closeSilently(inputReader);
+ StreamUtils.closeSilently(fr);
+ StreamUtils.closeSilently(jnlpReader);
}
if (JNLPRuntime.isDebug())
System.err.println("Ending check for signed JNLP file...");
}
- /***
- * Closes a stream
- *
- * @param stream the stream that will be closed
- */
- private void closeStream (Closeable stream) {
- if (stream != null)
- try {
- stream.close();
- } catch (Exception e) {
- e.printStackTrace(System.err);
- }
- }
-
/**
* Prompt the user for trust on all the signers that require approval.
* @throws LaunchException if the user does not approve every dialog prompt.
diff --git a/netx/net/sourceforge/jnlp/util/StreamUtils.java b/netx/net/sourceforge/jnlp/util/StreamUtils.java
index ed92fb6..3a179d5 100644
--- a/netx/net/sourceforge/jnlp/util/StreamUtils.java
+++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java
@@ -37,6 +37,7 @@ exception statement from your version.
package net.sourceforge.jnlp.util;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
@@ -55,4 +56,19 @@ public class StreamUtils {
in.close();
}
-} \ No newline at end of file
+ /***
+ * Closes a stream, without throwing IOException.
+ * In case of IOException, prints the stack trace to System.err.
+ *
+ * @param stream the stream that will be closed
+ */
+ public static void closeSilently (Closeable stream) {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+}