Uploaded image for project: 'ShrinkWrap'
  1. ShrinkWrap
  2. SHRINKWRAP-320

Empty Directory Causes FileNotFoundException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0-beta-6
    • 1.0.0-beta-5
    • impl-base
    • None
    • Hide

      @Test
      public void shouldBeAbleToAddEmptyDirectory()
      throws Exception

      { File resources = File.createTempFile("resources", null); resources.delete(); File svn = new File(resources, ".svn"); svn.mkdirs(); ShrinkWrap.create(JavaArchive.class) .addAsResource(resources, "/") .as(ZipExporter.class) .exportTo(new ByteArrayOutputStream()); }
      Show
      @Test public void shouldBeAbleToAddEmptyDirectory() throws Exception { File resources = File.createTempFile("resources", null); resources.delete(); File svn = new File(resources, ".svn"); svn.mkdirs(); ShrinkWrap.create(JavaArchive.class) .addAsResource(resources, "/") .as(ZipExporter.class) .exportTo(new ByteArrayOutputStream()); }

      Adding an empty directory as a resource to an archive causes a FileNotFoundException when exporting the archive.

      Looking at ContainerBase, it appears as though it is using file.listFiles() == 0 instead of isFile() or isDirectory()

      org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsResource(File resource, ArchivePath target)
      {
      ...
      if (files.length == 0)
      return addAsResource(new FileAsset(resource), target);

              tahintz_jira Tom Hintz (Inactive)
              tahintz_jira Tom Hintz (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: