Author: tn
Date: Wed Jan 16 09:51:52 2013
New Revision: 1433872

URL: http://svn.apache.org/viewvc?rev=1433872&view=rev
Log:
[VFS-285] Keep internal state consistent in case of an error of 
AbstractFileObject.getChildren(). Thanks to Kirill Safonov for the report.

Modified:
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java?rev=1433872&r1=1433871&r2=1433872&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
 Wed Jan 16 09:51:52 2013
@@ -896,14 +896,17 @@ public abstract class AbstractFileObject
             {
                 // Create file objects for the children
                 // children = new FileObject[files.length];
-                children = new FileName[files.length];
+                final FileName[] cache = new FileName[files.length];
                 for (int i = 0; i < files.length; i++)
                 {
                     final String file = files[i];
                     // children[i] = fs.resolveFile(name.resolveName(file, 
NameScope.CHILD));
                     // children[i] = name.resolveName(file, NameScope.CHILD);
-                    children[i] = fs.getFileSystemManager().resolveName(name, 
file, NameScope.CHILD);
+                    cache[i] = fs.getFileSystemManager().resolveName(name, 
file, NameScope.CHILD);
                 }
+                // VFS-285: only assign the children filenames after all of 
them have been
+                // resolved successfully to prevent an inconsistent internal 
state
+                children = cache;
             }
 
             return resolveFiles(children);

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1433872&r1=1433871&r2=1433872&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Wed Jan 16 09:51:52 2013
@@ -26,6 +26,10 @@
 <!--       <action issue="VFS-443" dev="ggregory" type="update" 
due-to="nickallen"> -->
 <!--           [Local] Need an easy way to convert from a FileObject to a 
File. -->
 <!--       </action> -->
+      <action issue="VFS-285" dev="tn" type="fix" due-to="Kirill Safonov">
+        AbstractFileObject.getChildren() may corrupt its internal state if a 
filename
+        can not be resolved.
+      </action>
       <action issue="VFS-451" dev="ggregory" type="fix" due-to="ilmarcoronchi">
         Authentication fails using private key.
       </action>


Reply via email to