Does AsynchronousSocketChannel.read(ByteBuffer) throw ShutdownChannelGroupException?
Gili
cowwoc at bbs.darktech.org
Wed Jun 24 17:41:15 PDT 2009
AsynchronousSocketChannel.read(ByteBuffer) overrides
AsynchronousByteChannel.read(ByteBuffer). The latter has no concept of
ChannelGroups so it does not declare that the method may throw
ShutdownChannelGroupException. AsynchronousSocketChannel, on the other hand,
declares that all I/O operation will throw ShutdownChannelGroupException if
the channel group is shut down in the middle of an operation.
There seems to be a conflict of specifications. Doesn't Design by Contract
specify that a subclass may throw less exceptions but it may not throw new
exceptions? I know that technically speaking all methods throw
RuntimeException but that's a little dirty. This exception does not indicate
programming error and it is quite reasonable to expect that developers will
want to catch it. At the very least,
AsynchronousSocketChannel.read(ByteBuffer)'s documentation should address
this more explicitly.
Thank you,
Gili
--
View this message in context: http://n2.nabble.com/Does-AsynchronousSocketChannel.read%28ByteBuffer%29-throw-ShutdownChannelGroupException--tp3152470p3152470.html
Sent from the nio-discuss mailing list archive at Nabble.com.
More information about the nio-discuss
mailing list