diff options
author | Sven Gothel <[email protected]> | 2012-03-10 03:32:29 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-10 03:32:29 +0100 |
commit | 24f8694a188b4a5255d4ac4f8b49982bd8ad3228 (patch) | |
tree | 1856155e530640b666a1d0a8574c851244eb9e22 /src/java/com/jogamp/common/util/VersionUtil.java | |
parent | 227ad20f6bf10d5d28073dfbd3fac363e3a09531 (diff) |
Stabilize open InputStream's / Closeable's: Decorate w/ try-finally and close within the latter
Diffstat (limited to 'src/java/com/jogamp/common/util/VersionUtil.java')
-rw-r--r-- | src/java/com/jogamp/common/util/VersionUtil.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 157edaa..30b23f2 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -32,6 +32,7 @@ import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Iterator; @@ -90,10 +91,17 @@ public class VersionUtil { * @return the requested manifest or null when not found. */ public static Manifest getManifest(ClassLoader cl, String extension) { + try { - Enumeration resources = cl.getResources("META-INF/MANIFEST.MF"); + Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { - Manifest manifest = new Manifest(((URL)resources.nextElement()).openStream()); + final InputStream is = resources.nextElement().openStream(); + final Manifest manifest; + try { + manifest = new Manifest(is); + } finally { + IOUtil.close(is, false); + } Attributes attributes = manifest.getMainAttributes(); if(attributes != null && extension.equals(attributes.getValue(Attributes.Name.EXTENSION_NAME))) { return manifest; |