RFR JDK-8024832: (so) ServerSocketChannel.socket().accept() throws IllegalBlockingModeException if not bound

Pavel Rappo pavel.rappo at oracle.com
Tue May 27 10:19:45 UTC 2014


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.
            
-Pavel

On 27 May 2014, at 11:03, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> On 27/05/2014 10:40, Pavel Rappo wrote:
>> Hi everyone,
>> 
>> Could you please review my change for JDK-8024832?
>> 
>> http://cr.openjdk.java.net/~prappo/8024832/webrev.00/
>> 
> Can you try just removing the isBound check? I ask because ssc.accept() will throw NotYetBoundException if the ServerSocketChannel is not bound and that should get mapped to the SocketException to match ServerSocket behavior.
> 
> -Alan.



More information about the nio-dev mailing list