On Mon, May 5, 2014 at 7:09 PM, Roger Whitcomb <[email protected]>wrote:
> So, the reason is that HdfsFileObject.equals only compares the paths, and
> not the HdfsFileSystem object it is attached to.
>
> @Override
> 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.
>
Great news as we are gearing up for a 2.1 release.
Gary
>
> Thanks,
> ~Roger Whitcomb
>
> -----Original Message-----
> From: Roger Whitcomb [mailto:[email protected]]
> Sent: Monday, May 05, 2014 3:41 PM
> To: Commons Users List
> Subject: [VFS] Funny result for HDFS FileObject.equals
>
> Hi,
> 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, rootDirectory.exists());
> 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;
> selectedFiles.clear();
> 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/])?
> True
>
> Thanks,
> ~Roger Whitcomb
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory