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

FileURLConnection fails on relative URLs working on stock Java handler

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.2.9.Final
    • 3.2.5.Final
    • Release
    • None

    Description

      A URL "file:./target/bundleA.txt" will not be handled appropriately by FileURLConnection resulting in the following exception:

      java.lang.IllegalArgumentException: VFS000021: path must not be null
              at org.jboss.vfs.VFS.getChild(VFS.java:175)
              at org.jboss.vfs.VFS.getChild(VFS.java:163)
              at org.jboss.vfs.protocol.FileURLConnection.<init>(FileURLConnection.java:51)
              at org.jboss.vfs.protocol.FileURLStreamHandler.openConnection(FileURLStreamHandler.java:38)
              at java.net.URL.openConnection(URL.java:972)
              at java.net.URL.openStream(URL.java:1038)
              at org.jboss.osgi.repository.spi.FileBasedRepositoryStorage.getResourceContent(FileBasedRepositoryStorage.java:225)
              at org.jboss.osgi.repository.spi.FileBasedRepositoryStorage.createResourceInternal(FileBasedRepositoryStorage.java:201)
              at org.jboss.osgi.repository.spi.FileBasedRepositoryStorage.addContentResource(FileBasedRepositoryStorage.java:140)
              at org.jboss.osgi.repository.spi.FileBasedRepositoryStorage.addResourceInternal(FileBasedRepositoryStorage.java:122)
              at org.jboss.osgi.repository.spi.FileBasedRepositoryStorage.addResource(FileBasedRepositoryStorage.java:107)
      

      The reason is that in the following code

          public static VirtualFile getChild(URI uri) {
              return getChild(uri.getPath());
          }
      

      uri.getPath() will return null due to URI being constructed from URL not being parsed as hierarchical only evaluating to "scheme-specific-part".

      This behavior is different from a stock Java file URL handler that will accept "file:./target/bundleA.txt" and handle it appropriately.

      A possible fix would be to call uri.getPath() first and if that returns null, fallback onto uri.getSchemeSpecificPart().

      Attachments

        Activity

          People

            tomazcerar Tomaž Cerar (Inactive)
            arcivanov_jira Arcadiy Ivanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified