JDK-8144300 : Java does not honor http.nonProxyHosts value having wildcard * both at end and start
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7u80,8u60,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2008
  • CPU: x86
  • Submitted: 2015-10-01
  • Updated: 2018-04-04
  • Resolved: 2018-03-28
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.
JDK 11
11 b07Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 2008 R2 SP1 x84

A DESCRIPTION OF THE PROBLEM :
Java programs does not honor http.nonProxyHosts value having wildcard * at end as shown:

http.nonProxyHosts="*.google.*"


Connections to say www.google.com still via Proxy rather than going Direct.




REGRESSION.  Last worked in version 8u60

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Install a simple Proxy Server in a machine

2) Compile and run the source code given below in another machine (not the Proxy machine) with following argument:

java -Dhttps.proxyHost=10.**.*.*** -Dhttps.proxyPort=808 -Dhttp.nonProxyHosts="*.google.*" testProxy.ProxyTest








EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"https://www.google.com" connection traffic must not go via Proxy, it should go via Direct connection
ACTUAL -
"https://www.google.com" connection traffic still goes via Proxy

Proxy logs show CONNECT :

15:53:14	Unknown	10.75.3.180	CONNECT www.google.com:443 HTTP/1.1 HTTPS outgoing via 10.**.*.***

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package testProxy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Example:
 * 
 * java.exe -Dhttps.proxyHost=10.11.1.111 -Dhttps.proxyPort=808 -Dhttp.nonProxyHosts="*.google.*" testProxy.ProxyTest
 */
public class ProxyTest {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		String url = "https://www.google.com";
		
		URL obj = new URL(url);
		HttpURLConnection con = (HttpURLConnection) obj.openConnection();
		con.setRequestMethod("GET");
		int responseCode = con.getResponseCode();
		System.out.println("\nSending 'GET' request to URL : " + url);
		System.out.println("Response Code : " + responseCode);

		BufferedReader in = new BufferedReader(
		        new InputStreamReader(con.getInputStream()));
		String inputLine;
		StringBuffer response = new StringBuffer();

		while ((inputLine = in.readLine()) != null) {
			response.append(inputLine);
		}
		in.close();

		
		System.out.println("Response: \n" + response.toString());
	}

}

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

CUSTOMER SUBMITTED WORKAROUND :
None available


Comments
Review Request : http://mail.openjdk.java.net/pipermail/net-dev/2018-March/011223.html
06-03-2018

JDK-8023648 looks similar, except that it is mac-osx specific.
01-12-2015

Removing the regression label, as the outputs are identical on JDK 7, 8u66 and 9ea. Attached Test case was run on : JDK 7 -Fail JDK 7u80 - Fail JDK 8u66 - Fail JDK 9ea b85 - Fail
01-12-2015