6881498: (file) Re-examine DirectoryStream exception handling

Alan Bateman Alan.Bateman at oracle.com
Fri Sep 10 03:03:01 PDT 2010


The exception handling in java.nio.file.DirectoryStream is currently 
painful, at least if you want to recover from I/O errors.  Joe, Doug, 
and I have been talking about improving this. The changes here introduce 
a more specific exception, DirectoryIteratorException, that is thrown if 
an I/O error is encountered. That's a bit more obvious than catching 
ConcurrentModificationException and looking at the cause to distinguish 
I/O errors from other causes. The closed stream case is changed so that 
the iterator behaves as if end of stream has been reached. The remove 
operation was originally specified to attempt to delete the directory. 
That was probably a bad idea and is now changed to be unsupported.

The webrev with the changes is here:
   http://cr.openjdk.java.net/~alanb/6881498/webrev/

Thanks,
Alan.


More information about the nio-dev mailing list