From 59233334144dca83fb017795d54d99636cccee81 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Wed, 27 Nov 2013 14:11:13 +0100 Subject: 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. --- netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java') 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 { -- cgit v1.2.3