commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes Scharf (JIRA)" <>
Subject [jira] Created: (VFS-295) Unsafe comparison in getParent() of AbstractFileObject
Date Fri, 08 Jan 2010 14:00:58 GMT
Unsafe comparison in getParent() of AbstractFileObject

                 Key: VFS-295
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 1.0
            Reporter: Johannes Scharf

When a AbstractFileObject is decorated, eg when "ON_CALL" CacheStrategy is used, a NullPointerException
is thrown.
This happens due an 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();
                // 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).

	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(
	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(
	at org.apache.commons.vfs.provider.AbstractFileObject.getParent(
	at org.apache.commons.vfs.impl.DecoratedFileObject.refresh(
	at org.apache.commons.vfs.cache.OnCallRefreshFileObject.resolveFile(
	at at.js.jtransporter.transporter.VFSTransporter.createFile(
	at at.js.jtransporter.worker.resource.ResourceWorker.createFile(
	at at.js.jtransporter.worker.resource.ResourceWorker.processJob(
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
	at java.util.concurrent.ThreadPoolExecutor$

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

View raw message