On 05/03/2010 04:24 PM, Sahoo (JIRA) wrote:
> Possible NPE for jars with null Manifest
> ----------------------------------------
>
> Key: FELIX-2318
> URL: https://issues.apache.org/jira/browse/FELIX-2318
> Project: Felix
> Issue Type: Bug
> Components: File Install
> Reporter: Sahoo
>
>
> JarFile.getManifest() can return null, so caller must check return value for
> null-ness to avoid NPE. I see two such occurrences in fileinstall:
>
> DirectoryWatcher.java:
> private Bundle installOrUpdateBundle(
> String bundleLocation, BufferedInputStream is, long checksum)
> throws IOException, BundleException
> {
> is.mark(256 * 1024);
> JarInputStream jar = new JarInputStream(is);
> Manifest m = jar.getManifest();
> String sn =
> m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
> ...
>
> BundleTransformer.java:
> Manifest m = jar.getManifest();
> if (m.getMainAttributes().getValue(new
> Attributes.Name("Bundle-SymbolicName")) != null)
> ...
>
>
Hello *,
it's really funny: I just ran into this problem; that's why I subscribed
to the mailing list and one of the first messages I read on this list is
exactly about this problem.
I assume that it is documented that META-INF must be the first entry in
a JAR and META-INF/MANIFEST.MF the second, but very likely there's a
huge number of JARs out there which doesn't stick to this rule.
I recommend to throw a meaningful exception (it took my quite some time,
decompiling and debugging to find it):
if (m == null)
throw new BundleException(
String.format(
"The bundle %s does not have a META-INF/MANIFEST.MF! "+
"Make sure, META-INF and MANIFEST.MF are the first 2 entries in
your JAR!",
bundleLocation
)
);
Best regards, Marco :-)
--
______________________________________________
*** BIKT - Bundesverband Informations- & ***
*** Kommunikationstechnologie e.V. ***
*** http://www.bikt.de ***
______________________________________________
*** OpenSource * Freie/Free Software ***
*** ERP (Enterprise Resource Planning) ***
*** CRM (Customer Relationship Management) ***
*** SCM (Supply Chain Management) ***
*** BPM (Business Process Management) ***
*** http://www.jfire.org ***
______________________________________________
Marco หงุ่ยตระกูล-Schulze NightLabs GmbH
Weiherhofstr. 16
79104 Freiburg
Germany
eMail: [email protected]
Fon: +49-761-88 79 18-88
Mobile: +49-172-212 63 80
Fax: +49-761-88 79 18-99
WWW: http://www.NightLabs.de
Geschäftsführung:
Marco Schulze <[email protected]>
Niklas Schiffler <[email protected]>
Eintragung:
Amtsgericht Freiburg, HRB 6186
______________________________________________