On 27/05/2014 11:19, Pavel Rappo wrote:
Alan,
I don't think it would be exactly the same behaviour since there's a
conditional check (1) before the ssc.accept call:
try {
if (!ssc.isBound())
throw new NotYetBoundException();
(1) if (timeout == 0) {
SocketChannel sc = ssc.accept();
if (sc == null && !ssc.isBlocking())
throw new IllegalBlockingModeException();
return sc.socket();
}
(2) ssc.configureBlocking(false);
try {
SocketChannel sc;
(3) if ((sc = ssc.accept()) != null)
So if I remove this explicit check, than depending on condition (1) it can be
the case that (3) will be executed after (2). And (2) can throw a bunch of
different exceptions, hiding the otherwise initial NotYetBoundException.
If it's not a concern I'm happy to remove this check.
For the no-timeout case then it would be the same. For the timeout case
it it just means that the channel might be changed to non-blocking
before the exception is thrown. I don't think this is a problem as it
will be restored anyway. What you have is fine, I think just removing is
fine too.
-Alan.