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

ConnectionException is thrown even when connection is successfull.

XMLWordPrintable

    • 11
    • sparc
    • solaris_8

      ConnectionException is thrown even when connection suceeds. This problem happens when java.net.connectiontimeout is set.

      The following example runs fine without the connectiontimeout set but will throw a ConnectionException if the timeout is set.

      import java.net.*;

      public class Test {
      public static void main(String[] args) {
      try {
                            for (int i = 0 ; i < 10; i++) {
      System.out.println("test");
      Socket s = new Socket("localhost", 13);
      s.close();
      }
      } catch (Exception e) {
      e.printStackTrace();
      }
      }
      }

      java -Djava.net.connectiontimeout=10 Test -> Fails
      java Test -> Works

      This problem happens in 1.2.2_09 & 1.3.1 as well.

            myangsunw Mingyao Yang (Inactive)
            arajadur Angelo Rajadurai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: