commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roger Whitcomb <>
Subject RE: [VFS] Funny result for HDFS FileObject.equals
Date Mon, 05 May 2014 23:09:52 GMT
So, the reason is that HdfsFileObject.equals only compares the paths, and not the HdfsFileSystem
object it is attached to.

    public boolean equals(final Object o)
        if (null == o)
            return false;
        if (o == this)
            return true;
        if (o instanceof HdfsFileObject)
            final HdfsFileObject other = (HdfsFileObject) o;
            if (other.path.equals(this.path))
                return true;
        return false;

And likewise, "hashCode" only returns the hash of the path.

Think I will file a JIRA with a patch for this.

~Roger Whitcomb

-----Original Message-----
From: Roger Whitcomb [] 
Sent: Monday, May 05, 2014 3:41 PM
To: Commons Users List
Subject: [VFS] Funny result for HDFS FileObject.equals

                I'm using Commons VFS inside an Apache Pivot remote file browser and I'm getting
a strange result when switching between different HDFS hosts.  I have two FileObjects, with
different host:port (but the same directory name), and they compare equal (i.e., the FileObject.equals(...)
method returns true, when they are clearly not the same.  Any thoughts?
                Here is the code and my results:
System.out.format("VFSBrowserSheet.setRootDirectory: does '%1$s' exist()? %2$s%n", rootDirectory,
        if (rootDirectory.exists()) {
            FileObject previousRootDirectory = this.rootDirectory;

System.out.format("VFSBrowserSheet.setRootDirectory: previousRootDirectory = %1$s%n", previousRootDirectory);
System.out.format("VFSBrowserSheet.setRootDirectory: rootDirectory[%1$s].equals(previousRootDirectory[%2$s])?
%3$s%n", rootDirectory, previousRootDirectory, rootDirectory.equals(previousRootDirectory));
            if (!rootDirectory.equals(previousRootDirectory)) {
                this.rootDirectory = rootDirectory;
System.out.format("VFSBrowserSheet.setRootDirectory, calling 'rootDirectoryChanged'%n");
                fileBrowserSheetListeners.rootDirectoryChanged(this, previousRootDirectory);

VFSBrowserSheet.setRootDirectory: does 'hdfs://chhadoop-master:9000/' exist()? true
VFSBrowserSheet.setRootDirectory: previousRootDirectory = hdfs://chcluster2-master:8020/
VFSBrowserSheet.setRootDirectory: rootDirectory[hdfs://chhadoop-master:9000/].equals(previousRootDirectory[hdfs://chcluster2-master:8020/])?

~Roger Whitcomb

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message