8025619: (fc) FileInputStream.getChannel on closed stream returns FileChannel that doesn't know that stream is closed

Brian Burkhalter brian.burkhalter at oracle.com
Thu Nov 27 00:35:38 UTC 2014


Please review at your convenience:

Issue:	https://bugs.openjdk.java.net/browse/JDK-8025619
Patch:	http://cr.openjdk.java.net/~bpb/8025619/webrev.00/

This patch fixes the immediate problem encountered by the test included in the issue description. The fix is simply for FileKey.create() to throw an IOException directly instead of wrapping it in an Error.

This raises the question of whether some additional verbiage in the description of getChannel() might be necessary to remind that calling close() on the source object will render the FileChannel inviable and possibly cause unforeseen subsequent exceptions.

Also, as noted in the issue comments, it begs the question as to whether getChannel() in FileInputStream, FileOutputStream, RendomAccessFile, etc., should return null or throw an IOException if the object on which it is invoked has already been closed. If so this would need to be addressed by an issue yet to be filed and would imply a documentation change.

Thanks,

Brian


More information about the nio-dev mailing list