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


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();
        }
    }


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

Reply via email to