Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-295

Unsafe comparison in getParent() of AbstractFileObject

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      When a AbstractFileObject is decorated, eg when "ON_CALL" CacheStrategy is used, a NullPointerException is thrown.
      This happens due a unsafe comparison in getParent():

       public FileObject getParent() throws FileSystemException {
              if (this == fs.getRoot()) // Always false when this object is decorated
              {
                  if (fs.getParentLayer() != null)
                  {
                      // Return the parent of the parent layer
                      return fs.getParentLayer().getParent();
                  }
                  else
                  {
                      // Root file has no parent
                      return null;
                  }
              }
      // Rest of method omitted
      }
      

      fs.getRoot() returns the decorating object not the decorated. this is the plain decorated (wrapped) object . So the comparison is never true. This causes the wrong code to get executed and finally the NullPointerException (see below).

      Stacktrace:

       java.lang.NullPointerException
      	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:272)
      	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
      	at org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:512)
      	at at.js.jtransporter.support.vfs.FtpFileObject.getInfo(FtpFileObject.java:149)
      	at at.js.jtransporter.support.vfs.FtpFileObject.refresh(FtpFileObject.java:176)
      	at org.apache.commons.vfs.impl.DecoratedFileObject.refresh(DecoratedFileObject.java:170)
      	at org.apache.commons.vfs.cache.OnCallRefreshFileObject.resolveFile(OnCallRefreshFileObject.java:152)
      	at at.js.jtransporter.transporter.VFSTransporter.createFile(VFSTransporter.java:132)
      	at at.js.jtransporter.worker.resource.ResourceWorker.createFile(ResourceWorker.java:81)
      	at at.js.jtransporter.worker.resource.ResourceWorker.processJob(ResourceWorker.java:52)
      	at at.js.jtransporter.worker.AbstractRunnableWorker.run(AbstractRunnableWorker.java:82)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      	at java.lang.Thread.run(Thread.java:619)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                scharfj Johannes Scharf
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: