commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes Scharf (JIRA)" <j...@apache.org>
Subject [jira] Updated: (VFS-295) Unsafe comparison in getParent() of AbstractFileObject
Date Fri, 08 Jan 2010 14:02:54 GMT

     [ https://issues.apache.org/jira/browse/VFS-295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Johannes Scharf updated VFS-295:
--------------------------------

    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():
{code:java}
 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
}
{code}

*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:
{noformat}
 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)
{noformat}

  was:
When a AbstractFileObject is decorated, eg when "ON_CALL" CacheStrategy is used, a NullPointerException
is thrown.
This happens due an unsafe comparison in getParent():
{code:java}
 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
}
{code}

*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:
{noformat}
 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)
{noformat}


> Unsafe comparison in getParent() of AbstractFileObject
> ------------------------------------------------------
>
>                 Key: VFS-295
>                 URL: https://issues.apache.org/jira/browse/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 a unsafe comparison in getParent():
> {code:java}
>  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
> }
> {code}
> *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:
> {noformat}
>  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)
> {noformat}

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


Mime
View raw message