commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Gaillard (JIRA)" <j...@apache.org>
Subject [jira] Updated: (VFS-220) Wrong test in AbstractFileObject.endOutput may cause invalid list of children
Date Tue, 30 Sep 2008 20:13:44 GMT

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

Gilles Gaillard updated VFS-220:
--------------------------------

    Description: 
Method endOutput() is called when a file is created or an outputstream closed.
The current code says: 
{noformat} 
    if (getType() == FileType.IMAGINARY) {
        // File was created
        handleCreate(FileType.FILE);
    } else {
        // File has changed
        onChange();
    }
{noformat}
Calling getType() on a file that wasn't previously attached will cause the file to be attached
and therefore 
not return FileType.IMAGINARY since it's just been created. Hence the list of children in
the parent will 
become wrong.

To correct, replace the test by 'if (type == FileType.IMAGINARY)', and the method becomes:
{noformat}
    protected void endOutput() throws Exception
    {
        // NOTE: don't use getType() here
        if (type == FileType.IMAGINARY)
        {
            // File was created
            handleCreate(FileType.FILE);
        }
        else
        {
            // File has changed
            onChange();
        }
    }
{noformat}

  was:
Method endOutput() is called when a file is created or an outputstream closed.
The current code says:
    if (getType() == FileType.IMAGINARY) {
        // File was created
        handleCreate(FileType.FILE);
    } else {
        // File has changed
        onChange();
    }
Calling getType() on a file that wasn't previously attached will cause the file to be attached
and therefore 
not return FileType.IMAGINARY since it's just been created. Hence the list of children in
the parent will 
become wrong.

To correct, replace the test by 'if (type == FileType.IMAGINARY)', and the method becomes:

    protected void endOutput() throws Exception
    {
        // NOTE: don't use getType() here
        if (type == FileType.IMAGINARY)
        {
            // File was created
            handleCreate(FileType.FILE);
        }
        else
        {
            // File has changed
            onChange();
        }
    }



suppress format for code excerpt

> Wrong test in AbstractFileObject.endOutput may cause invalid list of children
> -----------------------------------------------------------------------------
>
>                 Key: VFS-220
>                 URL: https://issues.apache.org/jira/browse/VFS-220
>             Project: Commons VFS
>          Issue Type: Bug
>         Environment: all
>            Reporter: Gilles Gaillard
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Method endOutput() is called when a file is created or an outputstream closed.
> The current code says: 
> {noformat} 
>     if (getType() == FileType.IMAGINARY) {
>         // File was created
>         handleCreate(FileType.FILE);
>     } else {
>         // File has changed
>         onChange();
>     }
> {noformat}
> Calling getType() on a file that wasn't previously attached will cause the file to be
attached and therefore 
> not return FileType.IMAGINARY since it's just been created. Hence the list of children
in the parent will 
> become wrong.
> To correct, replace the test by 'if (type == FileType.IMAGINARY)', and the method becomes:
> {noformat}
>     protected void endOutput() throws Exception
>     {
>         // NOTE: don't use getType() here
>         if (type == FileType.IMAGINARY)
>         {
>             // File was created
>             handleCreate(FileType.FILE);
>         }
>         else
>         {
>             // File has changed
>             onChange();
>         }
>     }
> {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