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

Create specific Exception for SIGINT signal in Selector.select()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.1
    • core-libs
    • x86
    • linux



      Name: nt126004 Date: 12/09/2002


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Linux
      glibc-2.2.4-24 (not really relevant here..)

      A DESCRIPTION OF THE PROBLEM :
      The Selector implementation throws a generic
      IOException when a SIGINT (^C) is received while
      blocking on the select() method.

      Specifically, it is thrown at
      sun.nio.ch.PollArrayWrapper.poll0 (native)
      w/ "Interrupted system call" as its message.

      This behavior is within the spec. I think, however,
      it would be better if something more specific were
      thrown.

      I noticed this when writing a shutdown hook (a la
      Runtime.addShutdownHook ) for a non-blocking server
      and discovering that my exception handling was not
      working as I had intended.

      For now, I have to inspect the exception message
      in order to tell whether the exception is being
      thrown as a result of receiving SIGINT. This is not
      pretty and is certainly fragile.

      I suggest, therefore, that a more specific IOException
      (say something akin to the ClosedByInterruptException)
      be thrown when these types of signals cause the
      select() operation to fail, and then to document it
      in the API.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Write some code that blocks indefinitely on a selection
      operation
      2.Run the program, and wait 'till the selection operation is
      reached
      3.Kill the program with ^C
      4.Examine the stack trace

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER WORKAROUND :
      Examine the message in the IOException to detect
      whether the exception was thrown as a result of
      SIGINT
      (Review ID: 178496)
      ======================================================================

            mr Mark Reinhold
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: