-
Bug
-
Resolution: Done
-
Critical
-
1.0.0-alpha-13, 1.0.0-beta-1
-
None
Adding a Resource via the String representation pointing to a Resource loaded via a ClassLoader and stored in Jar results in NullPoiinterException.
StackTrace
java.lang.NullPointerException at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsManifestResource(ContainerBase.java:608) at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsManifestResource(ContainerBase.java:557) at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsManifestResource(ContainerBase.java:545) at org.jboss.shrinkwrap.impl.base.test.DynamicContainerTestBase.testAddManifestStringTargetResourceFromJar(DynamicContainerTestBase.java:303)
org.jboss.shrinkwrap.impl.base.test.DynamicContainerTestBase
@Test @ArchiveType(ManifestContainer.class) public void testAddManifestStringTargetResourceFromJar() throws Exception { getManifestContainer().addAsManifestResource("java/lang/String.class", "String.class"); ArchivePath testPath = new BasicPath(getManifestPath(), "String.class"); Assert.assertTrue( "Archive should contain " + testPath, getArchive().contains(testPath)); }
The faulty logic comes from ContainerBase.fileFromResource(String), a URL returned by CL.getResource when packaged in a Jar is not usable as a new File(url.getFile()), the returned value is in the format: file:/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar!/java/lang/String.class
The File has the following states:
- !file.isFile,
- !file.isDirectory
- !file.exists,
- file.listFiles == null
- new FileInputStream(file) throws FileNotFoundException