JDK-6481164 : HTTP Persistent connection cache not working with unreacheable Proxy
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-10-12
  • Updated: 2011-02-16
  • Resolved: 2006-12-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.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b101)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b101, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Assertion

   protected synchronized void putInKeepAliveCache() {
	if (inCache) {
	    assert false : "Duplicate put to keep alive cache";
	    return;
	}

in sun.net.www.http.HttpClient is being triggered.

Cause is that code in HttpClient::new

		if ((ret.proxy != null && ret.proxy.equals(p)) ||
		    (ret.proxy == null && p == null)) {
		    synchronized (ret) {
			ret.cachedHttpClient = true;
			assert ret.inCache;
			ret.inCache = false;
		    }
		}

when entry is extracted from cache is not causing "inCache" to be set to false as (for whatever reason) the supplied Proxy is (for example DIRECT) whereas the ret.proxy is "HTTP".

I've never really understood why you fallback to DIRECT when, for example, a defined HTTP proxy is unreachable, but its got to be something to do with this behaviour.

Anyway, the end result is that keep-alive connections are not kept alive as the connection extracted from the cache with inCache still set to TRUE is not returned to the cache when finished with


REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION Something seems to be wrong with the logic in the code quoted. More precisely I do believe it's missing an else statement, i.e. something should be done when the HttpClient we got from the cache has a different proxy than the one passed in argument. Right now that HttpClient instance is returned but it's not flagged as coming from the cache.
01-11-2006