JDK-6224843 : REGRESSION: Regression in Socket.connect's use of timeouts
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-02-03
  • Updated: 2010-04-02
  • Resolved: 2005-06-15
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
XP Pro - Service Pack 2
Microsoft Windows XP [Version 5.1.2600]


A DESCRIPTION OF THE PROBLEM :
Calling the connect(SockAddress dest, int timeout)  method of Socket does not timeout correctly on Windows in 1.5.0.

For instance, passing a timeout of 3 seconds to the connect call results in an actual timeout of over 10 seconds (times vary -  usually around 16 seconds).

This behaved correctly under 1.4.x.  Passing a 3 second timeout would return in 3 seconds.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile sample program.
2. Run, passing arguments for IP address  and timeout to use in Socket.connect() call.   To observe timeout misbehavior, pass an IP address on your local network for a machine that does not exist.  First arg is IP address, second is timeout in milliseconds.

Example: java socktest 192.168.0.50  3000


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect  output of:
connect timed out: 3000
(or just slightly over 3000)

Where 3000 is the timeout you pass in (3000 milliseconds in this case)
ACTUAL -
Output under 1.5 is a time much larger than the passed in time:
connect timed out: 16534


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.*;

public class socktest {
    public static void main(String [] args) throws Exception {
        Socket s = new Socket();
        long begin = System.currentTimeMillis();
        try {
            s.connect(new InetSocketAddress(args[0], 80), Integer.parseInt(args[1]));
        } catch (Exception e) {
            System.out.println(e.getMessage()+
                                                 ": "+
                                                 (System.currentTimeMillis()-begin));
        }
    }
}

---------- END SOURCE ----------

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-2-03 00:03:24 GMT

Comments
EVALUATION Finally reproduce the bug. This bug is a duplicate of 5092063. Additional notes - according to the comment in 'Work Around' section of 5092063, 'Long timeouts are due to DNS being badly configured. Customers experiencing this issue should try to fix the DNS configuration on the machines (i.e. make sure the DNS servers do exist)' 'badly configured' here reads as specifying a non-exist DNS server. A null DNS setting is not enough to reproduce the bug. ###@###.### 2005-06-15 08:10:11 GMT
15-06-2005