[jboss-jira] [JBoss JIRA] Commented: (JBVFS-147) Cannot read from vfs: protocol URL

John Bailey (JIRA) jira-events at lists.jboss.org
Wed Mar 10 12:21:37 EST 2010


    [ https://jira.jboss.org/jira/browse/JBVFS-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12519262#action_12519262 ] 

John Bailey commented on JBVFS-147:
-----------------------------------

VFS was update to provide a caller invoking a mount operation access to the source file used for mounting.  The mount source is preferable to the getting the physicalFile  before mounting as it actually returns the copy if created at mount time.  Most archive mounts will create a copy of the archive before opening the zip to avoid file locking issues.  So it is always better to use the mount source if you need access to the file.  

Below is an example for getting access to the mount source.
------
VirtualFile jarFile = VFS.getChild("/path/to/archive.jar");
MountHandle handle = VFS.mountZip(jarFile, jarFile, tempFileProvider);
File mountSource = handle.getMountSource();

// Do some stuff with either the VirtualFile or the source File

VFSUtils.safeClose(handle);
------

Note, the Automounter does not return MountHandles.  This is by design.  Use of the  Automounter should be restricted to situations where there is no clear way to hold onto the MountHandle for later cleanup.  So if you need access to the mount source, you will need to perform the VFS mount call without the Automounter, and preform the cleanup when finished with it.


> Cannot read from vfs: protocol URL
> ----------------------------------
>
>                 Key: JBVFS-147
>                 URL: https://jira.jboss.org/jira/browse/JBVFS-147
>             Project: JBoss VFS
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.0.0.CR3
>            Reporter: Thomas Diesler
>            Assignee: John Bailey
>             Fix For: 3.0.0.CR4
>
>
> Cannot read bytes from vfs: protocol URL
> URL url = new URL("vfs:/home/tdiesler/svn/jboss-osgi/projects/testing/trunk/target/test-libs/example-simple.jar/");
> URLConnection con = (URLConnection)url.openConnection();
> InputStream inputStream = con.getInputStream();
> int read = inputStream.read();
> read is -1

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list