Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7058336

(so) Socket adpator is not synchronized on channel state

    Details

    • Subcomponent:
    • Resolved In Build:
      b22
    • CPU:
      x86
    • OS:
      linux_redhat_5.0
    • Verification:
      Verified

      Backports

        Description

        When a customer try to do some operation for closed SocketChannel, the exception message does not seem appropriate.

        CONFIGURATION:
        JDK5u17/RHEL5

        TEST CASE:
        -------------------------------------------------------------
         import java.nio.channels.*;

         public class TestSocket {
          public static void main(String[] args) throws Exception {
           SocketChannel sc = SocketChannel.open();
            sc.configureBlocking(false);
            Selector sel = Selector.open();
            sc.register(sel, 0);
            sel.selectNow();
            sc.close();
            sc.socket().setTcpNoDelay(false);
          }
         }
         -------------------------------------------------------------

        REPRODUCE:
        Compile the attached test case and run

        The following message will show up.
        java.net.SocketException: Operation not supported
        at sun.nio.ch.Net.setIntOption0(Native Method)
        at sun.nio.ch.Net.setIntOption(Net.java:152)
        at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:372)
        at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
        at sun.nio.ch.SocketOptsImpl$IP$TCP.noDelay(SocketOptsImpl.java:284)
        at sun.nio.ch.OptionAdaptor.setTcpNoDelay(OptionAdaptor.java:48)
        at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:268)
        at com.sun.enterprise.web.connector.grizzly.SelectorThread.setSocketOptions(SelectorThread.java:1956)
        at com.sun.enterprise.web.connector.grizzly.SelectorThread.handleAccept(SelectorThread.java:1517)
                ....


        "Operation not Supported" is EOPNOTSUPP.
        So, the message,"Socket is closed" seems appropriate in this case
        like the following result in jdk7.

        ----
        Exception in thread "main" java.net.SocketException: Socket is closed
                at sun.nio.ch.Net.translateToSocketException(Net.java:105)
                at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:288)
                at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:321)
                at TestSocket.main(TestSocket.java:11)
        Caused by: java.nio.channels.ClosedChannelException
                at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:170)
                at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:286)
                ... 2 more
        ------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  coffeys Sean Coffey
                  Reporter:
                  tbaba Tadayuki Baba (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: