AsynchronousSocketChannel: abortable operations throw RuntimeException

Gili cowwoc at bbs.darktech.org
Wed Oct 13 06:17:26 PDT 2010



Alan Bateman wrote:
> 
> AsynchronousSocketChannel is connected to a stream connection so it 
> doesn't really make sense to continue to use the connection after an I/O 
> operation has been cancelled. However, you are right and this should 
> really be an IllegalStateException (which is what our implementation 
> does, but it's just not specified). I'll create a bug to track this.
> 

Excellent. Regarding AsynchronousSocketChannel, I wasn't implying that the
stream should be reusable after an abort. I was implying that the decision
whether to support or use aborting should occur at compile-time instead of
at runtime. Meaning:

1) Each implementation must specify whether it supports aborting in its
Javadoc
2) The interface should provide a method to query this capability at runtime
(in case someone has no way of knowing what implementation gets passed into
their method at runtime). This method should guarantee a constant value
throughout runtime (i.e. it's a compile-time decision).
3) The implementation should continue to throw IllegalStateException, but
users shouldn't need to trigger a read/write to find out whether the
implementation supports aborting because of #1 and #2. The
IllegalStateException is simply an indication that they should know better.

Do you agree?

Gili
-- 
View this message in context: http://nio-discuss.970641.n3.nabble.com/AsynchrnousSocketChannel-abortable-operations-throw-RuntimeException-tp1692482p1694317.html
Sent from the nio-discuss mailing list archive at Nabble.com.


More information about the nio-discuss mailing list