diff options
author | Jiri Vanek <[email protected]> | 2013-11-27 14:11:13 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-11-27 14:11:13 +0100 |
commit | 59233334144dca83fb017795d54d99636cccee81 (patch) | |
tree | a28c68f6af5745527ecd66e3620a440764ca2115 /netx/net/sourceforge/jnlp | |
parent | b8da03fd7a7aac183acebf7ccd26196ccafca9bc (diff) |
Added null check when getting manifest attributes for case of jar without manifest
* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: (getManifestAttribute) added check fo null manifest to prevent npe.
* /tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java: added test for npe from getManifestAttribute
* tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java: (createJarWithContents) enhanced to be able to create jar without manifest.
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r-- | netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index 3be3623..324bbc6 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -900,8 +900,12 @@ public class JNLPClassLoader extends URLClassLoader { JarFile mainJar = null; try { mainJar = new JarFile(f); - attributeValue = mainJar.getManifest(). - getMainAttributes().getValue(attribute); + Manifest manifest = mainJar.getManifest(); + if (manifest == null || manifest.getMainAttributes() == null){ + //yes, jars without manifest exists + return null; + } + attributeValue = manifest.getMainAttributes().getValue(attribute); } catch (IOException ioe) { attributeValue = null; } finally { |