hi mario,

thank you for your answer.

The current VFS implementation (if you do not use anything else then the only-working SoftRefFilesCache) ensures that two resolveFile will return the same object if you ask for the same filename, thus, in terms of VFS there is nothing bad with the object comparison.

that is what i was hoping as i saw the code for the first time. however i always got NPEs somewhere further up in stack. to me it seemed that the original cause was always the AbstractFileObject.getParent() method or more precisely the comparison

  if (this == fs.getRoot()) { ... };

which never evaluated to true, even if it should! so i tracked down the problem a bit further. the reason is the following: under certain circumstances my custom filesystemmanager uses CacheStrategy.ON_CALL. on resolving a file via this filesystem i therefore get an instance of a DecoratedFileObject, in fact an instance of OnCallRefreshFileObject. now when calling getParent() on a DecoratedFileObject the call is forwarded to the actual implementation of the file object, lets say LocalFileObject. then, in the above comparison the "this" pointer is an instance of LocalFileObject. however, "fs.getRoot()" which internally calls "resolveFile(rootName)" uses the same filesystem and therefore returns an instance of OnCallRefreshFileObject. comparing both, LocalFileObject and OnCallRefreshFileObject, via identity will never work. that's the problem!


there a several solutions:

1. in AbstractFileObject.getParent():

replace

  if (this == fs.getRoot()) { ... };

with

  FileObject root = fs.getRoot();
  if (root instanceof DecoratedFileObject) {
    root = ((DecoratedFileObject) root).getDecoratedFileObject();
  }
  if (this == root) { ... }


2. use equals for the above comparison and overwrite equals in AbstractFileObject in such way that the identity comparison respects decorated file objects.


3. use the file object's path for determinig equality (as in my last posting)



what do think is the best way?


regards,
stephan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to