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.
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.