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

InetAddress.isReachable(timeout) may not return after timout milliseconds

XMLWordPrintable

    • b21
    • generic
    • solaris
    • Verified

        FULL PRODUCT VERSION :
          java version "1.6.0_01"
          Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
          Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

          This issue is also reproducible with Java SE 5, and Open JDK 7 b18.

        ADDITIONAL OS VERSION INFORMATION :
           Solaris 10, but should be reproducible on any unix system.

        EXTRA RELEVANT SYSTEM CONFIGURATION :
          MUST run as root. You must be root to have priviliges to create raw sockets
          over which to send the ICMP ECHO. If you are not root then this problem
          cannot be reproduced.

        A DESCRIPTION OF THE PROBLEM :
          A java process that continuously loops for a reachable host will impact on the
          timeout of another java process that is in an isReachable call. That is, the
          call can be observed to not timeout after the said timeout time has elapsed.

        REPRODUCIBILITY :
          This bug can be reproduced always.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
          With root priviliges run:
           # java Loop <a reachable host>

           # java TimeoutTest <an unreachable host, e.g. 1.1.1.1>

           TimeoutTest will never exit!


        ---------- BEGIN SOURCE ----------
        /**
         * Loop.java
         */
        class Loop {
            public static void main(String[] args) throws Exception {

                InetAddress addr = InetAddress.getByName(args[0]);
                while( true ) {
                    addr.isReachable(1000);
                }
            }
        }

        /**
         * TimeoutTest.java
         */
        class TimeoutTest {
            public static void main(String[] args) throws Exception {
                InetAddress addr = InetAddress.getByName(args[0]);
                System.out.println("Start (timeout 5sec)");

                if (addr.isReachable(5000)) {
                    System.out.println("isReachable() : true");
                } else {
                    System.out.println("isReachable() : false");
                }
                System.out.println("Finish");
            }
        }
        ---------- END SOURCE ----------

              chegar Chris Hegarty
              chegar Chris Hegarty
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: