FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
and 1.5.0_06
ADDITIONAL OS VERSION INFORMATION :
Linux Fedora Core 4
A DESCRIPTION OF THE PROBLEM :
If you compile and run the following code, it works fine in windows but in Linux, it cannot detect the proxy host/port.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just compile and run the above code in a network setting where there is proxy set.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
proxy hostname : DIRECT
ACTUAL -
proxy hostname : DIRECT
No Proxy
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
import java.net.*;
public class testProxy {
public static void main(String[] args) {
try {
System.setProperty("java.net.useSystemProxies","true");
List l = ProxySelector.getDefault().select(
new URI("http://www.yahoo.com/"));
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
Proxy proxy = (Proxy) iter.next();
System.out.println("proxy hostname : " + proxy.type());
InetSocketAddress addr = (InetSocketAddress)
proxy.address();
if(addr == null) {
System.out.println("No Proxy");
} else {
System.out.println("proxy hostname : " +
addr.getHostName());
System.out.println("proxy port : " +
addr.getPort());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
|