8012930: (fs) Eliminate recursion from FileTreeWalker

Alan Bateman Alan.Bateman at oracle.com
Tue Apr 23 02:12:47 PDT 2013


This patch eliminates the recursion from the FileTreeWalker utility 
class used by Files.walkFileTree, replacing it with its own walking 
stack.  While stack overflow hasn't been a problem, it can be mildly 
annoying to see a lot of walk methods in the stack trace when an 
exception occurs when deep in the file system. The other motivation of 
course is that the events make it more generally useful, particularly 
with the proposed API additions that flatten the nodes to a stream. With 
the change then FileTreeWalker will simply provide a sequence of events 
corresponding to the files in the tree; the dispatching to FileVisitor 
methods is moved to Files.walkFileTree.

The other thing in this patch is splitting out of the tests from the 
walk_file_tree.sh test. This shell test was originally intended to test 
walkFileTree against the native "find" program but it ended up running 
several other tests. It also turns out that SKIP_SUBTREE wasn't being 
tested so I've added a simple test for that.

The webrev with the changes is here:

http://cr.openjdk.java.net/~alanb/8012930/webrev

Thanks,

-Alan.


More information about the nio-dev mailing list