FULL PRODUCT VERSION :
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]. Should also apply to other OS
A DESCRIPTION OF THE PROBLEM :
When using an http proxy (with -Dhttp.proxyHost) and specifying proxy exceptions (-Dhttp.nonProxyHosts) there is a bug when an entry in the list of nonProxyHosts is a duplicate.
The reason is in the code of sun.net.spi.DefaultProxySelector at line 265:
try {
while (st.hasMoreTokens()) {
pool.add(st.nextToken().toLowerCase(), Boolean.TRUE);
}
} catch (sun.misc.REException ex) {
}
If a duplicate item is added to the pool, an REException is thrown and silently discarded. Thus, all remaining items will not be added to the pool. A possible fix for this is, to add an additional paramter to the add method in line 265:
pool.add(st.nextToken().toLowerCase(), Boolean.TRUE, true);
This will skip the exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set nonProxyHosts with duplicate items. E.g.:
-Dhttp.nonProxyHosts=example.com|example.com|myproxyexception.com
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The domain myproxyexception.com should not be called through the proxy.
ACTUAL -
The domain myproxyexception.com is called through the proxy.
REPRODUCIBILITY :
This bug can be reproduced always.