Name: akR10050 Date: 10/15/2003
Javadoc API specification for methods
ProxySelector.connectFailed(URI, SocketAddress, IOException)
ProxySelector.select(URI)
specifies that IllegalArgumentException has to be thrown when either argument of
these methods is null.
However, with the default ProxySelector provided with the RI, in case of
connectFailed(*) no exception is thrown, and select() throws
NullPointerException.
The behaviour of the connectFailed method can be verified with the following
testcase:
-------------- Test46.java -----------------------------------------------------------
import java.net.*;
import java.io.*;
public class Test46 {
public static void main(String[] args) {
PrintStream ref = System.out;
int errors = 0;
ProxySelector ps = ProxySelector.getDefault();
URI[] uris = null;
try {
uris = new URI[] { null, new URI("http://java.sun.com") };
} catch (URISyntaxException use) {
ref.println("Unexpected URISyntaxException");
return;
}
SocketAddress[] sas = null;
try {
sas = new SocketAddress[] { null,
new InetSocketAddress(InetAddress.getLocalHost(), 0)
};
} catch (UnknownHostException uhe) {
ref.println("Unexpected UknownHostException");
return;
} catch (IllegalArgumentException iae) {
ref.println("Unexpected IllegalArgumentException");
return;
}
IOException[] ioes = new IOException[] { null,
new IOException("test") };
boolean passed = false;
for (int i=0; i <uris.length; i++) {
for (int j=0; j < sas.length; j++) {
for (int k=0; k < ioes.length; k++ ) {
try {
ps.connectFailed(uris[i], sas[j], ioes[k]);
ref.println("No exception thrown");
} catch (IllegalArgumentException iae) {
passed = true;
} catch (NullPointerException npe) {
ref.println("NullPointerException thrown");
} finally {
if ( ( uris[i] == null || sas[j] == null
|| ioes[k] == null ) && !passed ) {
ref.println("connectFailed should have thrown"
+ " IllegalArgumentException:");
ref.println("uri: " + uris[i]);
ref.println("sa: " + sas[j]);
ref.println("ioe: " + ioes[k]);
errors++;
} else if ( uris[i] != null && sas[j]!= null
&& ioes[k] != null && passed ) {
ref.println("connectFailed should have not thrown"
+ " IllegalArgumentException:");
ref.println("uri: " + uris[i]);
ref.println("sa: " + sas[j]);
ref.println("ioe: " + ioes[k]);
errors++;
}
passed = false;
}
}
}
}
if ( errors> 0 ) {
ref.println(errors + " errors during the test");
return;
}
ref.println("Test passed");
ref.flush();
return;
}
}
--------------- End of Test46.java ---------------------------------------------------
======================================================================
###@###.### 2004-09-20
Javadoc API specification for methods
ProxySelector.connectFailed(URI, SocketAddress, IOException)
ProxySelector.select(URI)
specifies that IllegalArgumentException has to be thrown when either argument of
these methods is null.
However, with the default ProxySelector provided with the RI, in case of
connectFailed(*) no exception is thrown, and select() throws
NullPointerException.
The behaviour of the connectFailed method can be verified with the following
testcase:
-------------- Test46.java -----------------------------------------------------------
import java.net.*;
import java.io.*;
public class Test46 {
public static void main(String[] args) {
PrintStream ref = System.out;
int errors = 0;
ProxySelector ps = ProxySelector.getDefault();
URI[] uris = null;
try {
uris = new URI[] { null, new URI("http://java.sun.com") };
} catch (URISyntaxException use) {
ref.println("Unexpected URISyntaxException");
return;
}
SocketAddress[] sas = null;
try {
sas = new SocketAddress[] { null,
new InetSocketAddress(InetAddress.getLocalHost(), 0)
};
} catch (UnknownHostException uhe) {
ref.println("Unexpected UknownHostException");
return;
} catch (IllegalArgumentException iae) {
ref.println("Unexpected IllegalArgumentException");
return;
}
IOException[] ioes = new IOException[] { null,
new IOException("test") };
boolean passed = false;
for (int i=0; i <uris.length; i++) {
for (int j=0; j < sas.length; j++) {
for (int k=0; k < ioes.length; k++ ) {
try {
ps.connectFailed(uris[i], sas[j], ioes[k]);
ref.println("No exception thrown");
} catch (IllegalArgumentException iae) {
passed = true;
} catch (NullPointerException npe) {
ref.println("NullPointerException thrown");
} finally {
if ( ( uris[i] == null || sas[j] == null
|| ioes[k] == null ) && !passed ) {
ref.println("connectFailed should have thrown"
+ " IllegalArgumentException:");
ref.println("uri: " + uris[i]);
ref.println("sa: " + sas[j]);
ref.println("ioe: " + ioes[k]);
errors++;
} else if ( uris[i] != null && sas[j]!= null
&& ioes[k] != null && passed ) {
ref.println("connectFailed should have not thrown"
+ " IllegalArgumentException:");
ref.println("uri: " + uris[i]);
ref.println("sa: " + sas[j]);
ref.println("ioe: " + ioes[k]);
errors++;
}
passed = false;
}
}
}
}
if ( errors> 0 ) {
ref.println(errors + " errors during the test");
return;
}
ref.println("Test passed");
ref.flush();
return;
}
}
--------------- End of Test46.java ---------------------------------------------------
======================================================================
###@###.### 2004-09-20
- relates to
-
JDK-5052573 No IAE from com.sun.deploy.net.proxy.DeployProxySelector.connectFailed
- Closed