Name: mtR10145 Date: 12/09/2003
Code below illustrates that IOException message from
URLConnection.coonect lacks mentioning that this is IOException
namely java.net.ConnectException is mentioned instead). This can
mislead application developer and make problems investigation more
difficult.
=================== Test.java ======================
import java.net.*;
import java.io.IOException;
public class Test {
public static void main(String argv[]) {
URLConnection urlc = null;
try {
urlc = new URL("https://foo.com").openConnection();
} catch (IOException ioe) {
System.out.println("Unexpected: " + ioe);
}
try {
urlc.connect();
} catch(SecurityException se) {
System.out.println("SecurityException thrown: " + se);
} catch(java.io.IOException ioe) {
// the problem is here
System.out.println("IOException thrown: " + ioe);
}
}
}
============== Test output with JSE 1.5.0-beta-b25 ==========
IOException thrown: java.net.ConnectException: Connection refused: connect
======================================================================