commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Didier Earith (JIRA)" <j...@apache.org>
Subject [jira] Commented: (VFS-279) ClassCastException in LocalFileSystem when using OnCall caching
Date Mon, 09 Nov 2009 09:08:32 GMT

    [ https://issues.apache.org/jira/browse/VFS-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774906#action_12774906
] 

Didier Earith commented on VFS-279:
-----------------------------------

Here is a simple test to reproduce the issue:

The test consists in calling 'resolveFile' with an uri (to a directory) which is contained
into a jar file.



public class TestVFS {

    public static void main(String[] args) {
        
        testBugDoReplicateFile();
        
    }

    public static void testBugDoReplicateFile() {

        StandardFileSystemManager standardFileSystemManager = new StandardFileSystemManager();
        standardFileSystemManager.setLogger(LogFactory.getLog(VFS.class));
        standardFileSystemManager.setClassLoader(TestVFS.class.getClassLoader());
        try {
            URL configUrl = new URL("file:/C:/MyVFSProvider.xml");
            standardFileSystemManager.setConfiguration(configUrl);
            standardFileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
            standardFileSystemManager.init();

            String uri = "jar:file:/C:/MyJarFile!/schema/iso19139";
            FileSystemOptions opts = new FileSystemOptions();

            FileObject fileObject = standardFileSystemManager.resolveFile(uri, opts);

        } catch (FileSystemException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}



The stack is :


LocalFileSystem.doReplicateFile(FileObject, FileSelector) line: 77	
LocalFileSystem(AbstractFileSystem).replicateFile(FileObject, FileSelector) line: 395	
JarFileSystem(ZipFileSystem).<init>(FileName, FileObject, FileSystemOptions) line: 63

JarFileSystem.<init>(FileName, FileObject, FileSystemOptions) line: 51	
JarFileProvider.doCreateFileSystem(String, FileObject, FileSystemOptions) line: 82	
JarFileProvider(AbstractLayeredFileProvider).createFileSystem(String, FileObject, FileSystemOptions)
line: 79	
JarFileProvider(AbstractLayeredFileProvider).findFile(FileObject, String, FileSystemOptions)
line: 59	
StandardFileSystemManager(DefaultFileSystemManager).resolveFile(FileObject, String, FileSystemOptions)
line: 691	
StandardFileSystemManager(DefaultFileSystemManager).resolveFile(String, FileSystemOptions)
line: 619	
TestVFS.testBugDoReplicateFile() line: 36	
TestVFS.main(String[]) line: 18	



In the doReplicateFile, the fileObject object  is  a OnCallRefreshFileObject instance  which
inherits from DecoratedFileObject :


fileObject	OnCallRefreshFileObject  (id=49)	
	decoratedFileObject	LocalFile  (id=57)	
		attached	true	
		children	null	
		content	null	
		file	File  (id=60)	
		fs	LocalFileSystem  (id=43)	
		name	WindowsFileName  (id=62)	
		objects	null	
		operations	null	
		parent	null	
		rootFile	"C:" (id=67)	
		type	FileType  (id=68)	





MyVFSProvider.xml is 

<?xml version="1.0" encoding="ISO-8859-1"?>
<providers>

<!-- 
    <default-provider class-name="org.apache.commons.vfs.provider.url.UrlFileProvider"/>
 -->
    <default-provider class-name="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider"/>
    
    <provider class-name="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider">
        <scheme name="local"/>
    </provider>
    
    <provider class-name="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider">
        <scheme name="file"/>
    </provider>

    <provider class-name="org.apache.commons.vfs.provider.ftp.FtpFileProvider">
        <scheme name="ftp"/>
        <if-available class-name="org.apache.commons.net.ftp.FTPFile"/>
    </provider>
    
    <provider class-name="org.apache.commons.vfs.provider.sftp.SftpFileProvider">
        <scheme name="sftp"/>
    </provider>

    <provider class-name="org.apache.commons.vfs.provider.http.HttpFileProvider">
        <scheme name="http"/>
    </provider>
    
    <provider class-name="org.apache.commons.vfs.provider.https.HttpsFileProvider">
        <scheme name="https"/>
    </provider>

    <provider class-name="org.apache.commons.vfs.provider.jar.JarFileProvider">
        <scheme name="jar"/>
    </provider>

</providers>


> ClassCastException in LocalFileSystem when using OnCall caching
> ---------------------------------------------------------------
>
>                 Key: VFS-279
>                 URL: https://issues.apache.org/jira/browse/VFS-279
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1, 2.0
>            Reporter: Didier Earith
>             Fix For: 1.0, 1.1, 2.0
>
>         Attachments: LocalFileSystem.java
>
>
> When using OnCall caching in the file system, there is a ClassCastException in the LocalFileSystem#doReplicateFile
function.
> To fix the issue, I replaced :
>         final LocalFile localFile = (LocalFile) fileObject;
> by 
>         final LocalFile localFile = (LocalFile) FileObjectUtils.getAbstractFileObject(fileObject);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message