From 7d11da0879ecfe284a5413c0a223fecf67e28deb Mon Sep 17 00:00:00 2001 From: Adam Domurad Date: Tue, 5 Mar 2013 16:35:40 -0500 Subject: Move stream closing utility in JNLPClassLoader to StreamUtils --- .../sourceforge/jnlp/runtime/JNLPClassLoader.java | 23 +++++----------------- netx/net/sourceforge/jnlp/util/StreamUtils.java | 18 ++++++++++++++++- 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'netx') 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); + } + } + } +} -- cgit v1.2.3