Uploaded image for project: 'JBoss VFS'
  1. JBoss VFS
  2. JBVFS-129

ZipEntryContext cannot handle directory paths with '+' symbols

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2.0.Alpha2
    • 2.2.0.Alpha1
    • None
    • None

    Description

      When trying to create/use a ZipEntryContext on a zip file whose absolute path contains '+' symbols, the createZipSource() throws an exception looking something like:

      Caused by: java.lang.RuntimeException: Failed to initialize ZipWrapper: /var/folders/JG/JGDYgcyPGF8WRpvalJeL0k+++TI/Tmp/slsb.jar
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getZipSource(ZipEntryContext.java:286)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:637)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:783)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChild(ZipEntryContext.java:827)
      at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.createChildHandler(ZipEntryHandler.java:195)
      at org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:690)
      at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:169)
      at org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:107)
      at org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:492)
      at org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure.determineStructure(DeclaredStructure.java:64)
      ... 40 more
      Caused by: java.io.FileNotFoundException: /var/folders/JG (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(FileInputStream.java:106)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.createZipSource(ZipEntryContext.java:361)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getZipSource(ZipEntryContext.java:282)
      ... 49 more

      Here's my understanding of the source of the problem, based on some debugging & research.
      ZipEntryContext uses URLDecoder.decode() (via VFSUtils.decode()) to convert a file path (which may contain quoted characters, e.g. %20) into a path that the single-String-arg File constructor understands. In the example above, the result is '/var/folders/JG/JGDYgcyPGF8WRpvalJeL0k TI/Tmp/slsb.jar', which is obviously incorrect.

      I think using URLDecoder.decode() is a faulty strategy. I'll attach my suggested fix.

      (This problem would especially cause problems for OS X users, since the OS X temp directory (always? often?) contains '+++' in its path. This is the case in the stacktrace above. A workaround for this particular problem is to use -Djava.io.tmpdir=/some/path/without/pluses)

      Attachments

        Activity

          People

            ajustin@redhat.com Ales Justin
            matt.drees2 Matt Drees (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: