6881498: (file) Re-examine DirectoryStream exception handling

Rémi Forax forax at univ-mlv.fr
Fri Sep 10 03:23:48 PDT 2010


  Le 10/09/2010 12:03, Alan Bateman a écrit :
>
> 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.

Looks good.
Only one comment, DirectoryIteratorException should have a constructor that
takes an IOException and a message.
Some implementations may want to provide a specific message.

Rémi




More information about the nio-dev mailing list