diff options
author | Adam Domurad <[email protected]> | 2013-04-23 12:30:34 -0400 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-04-23 12:30:34 -0400 |
commit | 01150bb7b4bf43e8d72167239c9402f99eedff60 (patch) | |
tree | 952948a73abfec899643dd794dc4a1b0684e491f /netx/net/sourceforge | |
parent | e8403ca8f62716fd3a76906b7e25cbc0d0cb5228 (diff) |
Ensure JarFile handles do not leak.
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r-- | netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index 28b3d43..dee9115 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -862,6 +862,8 @@ public class JNLPClassLoader extends URLClassLoader { break; } } + + jarFile.close(); } catch (IOException e) { /* * After this exception is caught, it is escaped. This will skip @@ -884,12 +886,15 @@ public class JNLPClassLoader extends URLClassLoader { File f = tracker.getCacheFile(location); if( f != null) { + JarFile mainJar = null; try { - JarFile mainJar = new JarFile(f); + mainJar = new JarFile(f); mainClass = mainJar.getManifest(). getMainAttributes().getValue("Main-Class"); } catch (IOException ioe) { mainClass = null; + } finally { + StreamUtils.closeSilently(mainJar); } } @@ -1305,6 +1310,7 @@ public class JNLPClassLoader extends URLClassLoader { jarEntries.add(je.getName()); } + jarFile.close(); } addURL(jar.getLocation()); @@ -1328,6 +1334,8 @@ public class JNLPClassLoader extends URLClassLoader { JarIndex index = JarIndex.getJarIndex(jarFile, null); if (index != null) jarIndexes.add(index); + + jarFile.close(); } else { CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), jar.getLocation()); } @@ -1401,6 +1409,7 @@ public class JNLPClassLoader extends URLClassLoader { new FileOutputStream(outFile)); } + jarFile.close(); } catch (IOException ex) { if (JNLPRuntime.isDebug()) ex.printStackTrace(); |