[shrinkwrap-issues] [JBoss JIRA] Commented: (SHRINKWRAP-306) URL.openStream on directory URLs from the ShrinkWrapClassLoader throw an NPE

Andrew Rubinger (JIRA) jira-events at lists.jboss.org
Thu Jul 21 21:49:23 EDT 2011


    [ https://issues.jboss.org/browse/SHRINKWRAP-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12615800#comment-12615800 ] 

Andrew Rubinger commented on SHRINKWRAP-306:
--------------------------------------------

Reported exception leading to this was via Eclipse JPA:

{code}Caused by: java.lang.NullPointerException
        at org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader$1$1.getInputStream(ShrinkWrapClassLoader.java:134)
        at java.net.URL.openStream(URL.java:1010)
        at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.isJarInputStream(ArchiveFactoryImpl.java:124)
        at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:106)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:213)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:134)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:125)
        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:98)
        ... 76 more{code}

> URL.openStream on directory URLs from the ShrinkWrapClassLoader throw an NPE
> ----------------------------------------------------------------------------
>
>                 Key: SHRINKWRAP-306
>                 URL: https://issues.jboss.org/browse/SHRINKWRAP-306
>             Project: ShrinkWrap
>          Issue Type: Bug
>          Components: api
>    Affects Versions: 1.0.0-beta-4
>            Reporter: Andrew Rubinger
>            Assignee: Andrew Rubinger
>             Fix For: 1.0.0-beta-5
>
>
> This case should show the problem:
>       // Make a new Archive with some content in a directory
>       final String nestedResourceName = "nested/test";
>       final Asset testAsset = new StringAsset("testContent");
>       final GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(testAsset, nestedResourceName);
>       
>       // Make a CL to load the content
>       final ClassLoader swCl = new ShrinkWrapClassLoader(archive);
>       // Get the URL to the parent directory
>       final URL nestedResourceUrl = swCl.getResource(nestedResourceName);
>       final URL nestedResourceUpALevelUrl = new URL(nestedResourceUrl, "../");
>       
>       // openStream on the URL to the parent directory; should return null, not throw an exception
>       final InputStream in = nestedResourceUpALevelUrl.openStream(); // << NPE
> Due to:
> https://github.com/shrinkwrap/shrinkwrap/blob/1.0.0-beta-4/api/src/main/java/org/jboss/shrinkwrap/api/classloader/ShrinkWrapClassLoader.java#L134
> If "getAsset" from Node is returning null, this is a directory.  So return a null InputStream to denote as such; don't throw an NPE.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the shrinkwrap-issues mailing list