JDK-8023648 : System property " http.nonProxyHosts " ignores IP address wildcards
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7u9
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • Submitted: 2013-05-02
  • Updated: 2018-09-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_09 " 
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Darwin prome-1s-dhcp94.eng.vmware.com 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
When calculating the proxy exceptionList on Mac OS X, the code in jdk/src/solaris/native/java/lang/java_props_macosx.c does not properly expand OS X-style IP exceptions (169.254/16, 10/8), and specifically ignores Java-style IP exceptions (169.254.*, 10.*).

This causes attempts to open a connection by IP address to incorrectly go through the proxy (if one is configured).

Ideally, the code in java_props_macosx.c should expand OS X-style IP wildcards (10/8) into Java-style (10.*), but at the very least, it should allow Java-style IP wildcards.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Set proxy bypass settings (System Preferences -> Network -> Advanced -> Proxies) to include IP address ranges, for example: *.local, 169.254/16
2) Print out System.getProperty( " http.nonProxyHosts " )
3) Try to get proxy for a 169.254/16 address: ProxySelector.getDefault().select(URI.create( " http://169.254.12.14/ " ))

4) Change proxy bypass settings to include Java-style IP range, for example: *.local, 169.254.*
5) Repeat step 2)
6) Repeat step 3)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Step 2: Should print out  " local|*.local|169.254.* " 
Step 3: Should return DIRECT
Step 5: Should print out  " local|*.local|169.254.* " 
Step 6: Should return DIRECT
ACTUAL -
Step 2: Returned HTTP @ proxy.eng.vmware.com:3128 (the configured HTTP proxy)
Step 3: local|*.local|169.254/16|*.169.254/16
Step 5: Returned HTTP @ proxy.eng.vmware.com:3128 (the configured HTTP proxy)
Step 6: local|*.local

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;

public class Prox {

    public static void main(String[] args) {
        System.out.println( " Non-proxy hosts:  "  + System.getProperty( " http.nonProxyHosts " ));
        System.out.println( " Proxies for 169.254.12.14: " );
        for (Proxy proxy : ProxySelector.getDefault().select(URI.create( " http://169.254.12.14 " ))) {
            System.out.println( "  -  "  + proxy);
        }
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I'd hoped that I could work around Java not understanding OS X's proxy bypass syntax for IP ranges (10/8, etc.) by using Java-style IP wildcards (10.*) in OS X's network settings, but the code in java_props_macosx.c specifically filters those out (if (strchr(c_exception, '*')) ...).

Only workaround I have for now is to not use ProxySelector, or manually set the http.nonProxyHosts property, but I'd prefer it being picked up correctly from the OS settings.