[jboss-jira] [JBoss JIRA] (JBVFS-200) FileURLConnection fails on relative URLs working on stock Java handler

Arcadiy Ivanov (JIRA) issues at jboss.org
Thu Dec 18 19:43:29 EST 2014


Arcadiy Ivanov created JBVFS-200:
------------------------------------

             Summary: FileURLConnection fails on relative URLs working on stock Java handler
                 Key: JBVFS-200
                 URL: https://issues.jboss.org/browse/JBVFS-200
             Project: JBoss VFS
          Issue Type: Bug
          Components: Release
    Affects Versions: 3.2.5.Final
            Reporter: Arcadiy Ivanov
            Assignee: Tomaz Cerar


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

{noformat}
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)
{noformat}

The reason is that in the following code

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

{{uri.getPath()}} will return {{null}}.

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

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




--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the jboss-jira mailing list