[jira] [Commented] (FELIX-2318) Possible NPE for jars with null Manifest

2017-05-16 Thread Andy Wu (JIRA)

[ 
https://issues.apache.org/jira/browse/FELIX-2318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16011998#comment-16011998
 ] 

Andy Wu commented on FELIX-2318:


thanks for your response , I will send a pr to github.

> 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
>Assignee: Guillaume Nodet
> Fix For: fileinstall-3.1.0
>
>
> 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)
> ...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-2318) Possible NPE for jars with null Manifest

2017-05-15 Thread Guillaume Nodet (JIRA)

[ 
https://issues.apache.org/jira/browse/FELIX-2318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16011848#comment-16011848
 ] 

Guillaume Nodet commented on FELIX-2318:


In this case, having to use JarInputStream would force the use of an 
intermediary file to copy the content of the input stream so that it can be 
opened using a JarFile.  Supporting that correctly might be doable in a proper 
way though, and if you're willing to provide a patch, please raise a new issue 
and attach a patch or PR, I'd be happy to help reviewing it.

> 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
>Assignee: Guillaume Nodet
> Fix For: fileinstall-3.1.0
>
>
> 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)
> ...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-2318) Possible NPE for jars with null Manifest

2017-05-15 Thread Andy Wu (JIRA)

[ 
https://issues.apache.org/jira/browse/FELIX-2318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16011661#comment-16011661
 ] 

Andy Wu commented on FELIX-2318:


I have a question about this , I didn't find the limit of META-INF/MANIFEST.MF 
must be the first file in the jar  , but java.util.jar.JarInputStream in jdk 
seems to make such assumption, but java.util.jar.JarFile can get MANIFEST.MF 
even if it is not the first file , so felix could use this class to get 
manifest information to avoid NPE. What do you think about this ? please let me 
know. thanks.

> 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
>Assignee: Guillaume Nodet
> Fix For: fileinstall-3.1.0
>
>
> 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)
> ...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] Commented: (FELIX-2318) Possible NPE for jars with null Manifest

2010-05-04 Thread Marco (JIRA)

[ 
https://issues.apache.org/jira/browse/FELIX-2318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12863839#action_12863839
 ] 

Marco commented on FELIX-2318:
--

Yesterday, I stumbled exactly over this NPE, which was not very developer 
friendly and forced me to dig quite deep into it (decompiling & debugging).

I'm not sure whether I can agree to Sahoo's suggestion to return a value in 
this case. I mean, if there is no proper MANIFEST, it is not a valid OSGi 
bundle and thus the method installOrUpdateBundle(...) cannot really return 
anything meaningful. Or am I overlooking anything?

Anyway, for me (and everyone else not being aware of the MANIFEST.MF being 
required at the very beginning of the JAR) a simple exception with a precise 
error message would have been most helpful. I therefore recommend to simply add 
sth. like this:

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
)
  );

> 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)
> ...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.