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

(so) SocketChannel.close() does not close immediately when channel is registered

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 6
    • 1.4.0
    • core-libs
    • None
    • b33
    • unknown
    • generic

    Description

      SocketChannel.close() is not closing the underlying
      socket when the channel is non blocking and registered with a
      Selector. [See comments for simple test case]

      The problem seems to be in the socket pre/post close logic
      and there are actually a couple of bugs I believe.

      1. On Unix the dummy version of NativeDispatcher.preClose()
         is being called instead of the one in FileDispatcher. This
         is because SocketDispatcher extends NativeDispatcher instead
         of FileDispatcher. So, if you make SocketDispatcher extend
         FileDispatcher, this fixes the problem on Unix.

      2. The problem also happens on Windows, presumably because the
         actual socket close should be happening (but is not) in the preClose()
         function.

      Strangely, this seems to be a long standing issue. I can reproduce with
      every release back to 1.4.0.

      Attachments

        Issue Links

          Activity

            People

              sherman Xueming Shen
              michaelm Michael McMahon
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: