7020888: (file) Miscellaneous and trivial clean-ups (typos and opportunities to use suppressed exceptions)

Alan Bateman Alan.Bateman at oracle.com
Sun Feb 20 08:45:11 PST 2011


Mike Duigou wrote:
> All look good to me. Catching Throwable in SocketChannel does looks a 
> little suspiciously broad. Other non-IOExceptions thrown in the 
> context of the sc.close() would cause the original x to be lost. One 
> can imagine an OutOfMemoryError being thrown especially if x is also 
> an OME.
>
> Mike
>
Thanks Mike. On catching throwable, I think the more precise rethrow 
works well here and avoids needing to catch each of the possible runtime 
exceptions that connect can throw. In addition it gives us the chance to 
close the channel's socket in the event that an Error is thrown. On 
close throwing something other than IOException then you are right, this 
would supplant the exception, just not sure if it's worth worrying about.

-Alan.


More information about the nio-dev mailing list