FULL PRODUCT VERSION :
1.5.0_04
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Bluecoat proxy
A DESCRIPTION OF THE PROBLEM :
I'm using a proxy for an applet that uses a HTTP communication layer. After a while (low levels when user is idle of communication between the client and server that's done using HTTP communication), with Java 1.5.0_05 on Windows (XP or 2000), I get the exception listed below. However, with Java 1.4.2, this does not occur. I'm not exactly sure what's happening and this only seems to happen in a certain environment as some locations with Bluecoat proxies do not experience the problem. It could be due to load or DNS issues.
Looking at the source, I'm not sure exactly how this situation would arrise. It would seem that in doTunneling() of HttpURLConnection that proxyHost would not be null except the first loop through. So if proxiedConnect(url, proxyHost, proxyPort, false) in doTunneling() got called the first time, the exception below would occur but if not then it should be not null.
In any result, this is a regression and should not be happening that the proxyHost is null. Communication works initially between the client and server using the proxy but 2 attempts both fail when the problem occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Exactly steps are not known. The application is doing multiple HTTP POSTS to an SSL host through a Bluecoat proxy. Initial attempts seem to work but it eventually fails and throws the NPE. It's theorized that it could relate to load of the proxy or a DNS issue.
Additional Information:
I have some additional information on this report that may be applicable. Doing a dump of the connection I saw two odd situations. The first one I'm seeing a CONNECT for the proxy followed by HTTP/1.1 which seems weird. The proxy is not returning an error in this situation:
[Note: the host names were changed for security purposes]
CONNECT gg
a3.gg.gg.com:443
HTTP/1.1..User-
Agent: Mozilla/4
.0 (Windows XP 5
.1) Java/1.5.0_0
5..Host: gga3.gg
.gg.com..Accept:
text/html, imag
e/gif, image/jpe
g, *; q=.2, */*;
q=.2....
Another time, I saw a CONNECT followed by a POST request which the proxy responded with a 400 Bad Request to. So it seems like bad requests are being sent sometimes and perhaps the JVM is not correctly handing the 400 response to the request:
[Note: Again, host names changed for security purposes]
....M<........E.
./$%@...........
...j...5A.hy..P.
..3}..CONNECT gg
a3.gg.gg.com:443
HTTP/1.1..POST /b/75d794f3/1501
528294.gif HTTP/
1.1..User-Agent:
Mozilla/4.0 (Wi
ndows XP 5.1) Ja
va/1.5.0_05..Hos
t: gga3.gg.gg.co
m..Accept: text/
html, image/gif,
image/jpeg, *; q=.2, */*; q=.2.
.Cache-Control: no-cache..Pragma
: no-cache..Prox
y-Connection: ke
ep-alive..Conten
t-type: applicat
ion/x-www-form-u
rlencoded..Conte
nt-Length: 32..C
ookie: PD-ID=tLO
wtT78DZmVixxWcgm
0Nerhj5REgPMX8-1
i+bJ74oY8x8dI68p
FpR7z7g78sVoQJHd
60qnUWMYj+DeSB4i
epSrap0NwcuaJtSW
UQ7fhWV3syh8NxV4
CnK1SVx2UPvBFAks
TGPaUJsI=....
***NOTE*** The connect request also has a post command embedded in it.
The Bluecoat Proxy server is returning a HTTP status 400 Bad
Request......
CONNECT gga3.gg.gg.com:443 HTTP/1.1..POST /b/75d794f3/1501528294.gif
HTTP/1.1..User-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.5.0_05..Host:
gga3.gg.gg.com..Accept: text/html, image/gif, image/jpeg, *; q=.2, */*;
q=.2..Cache-Control: no-cache..Pragma: no-cache..Proxy-Connection:
keep-alive..Content-type:
application/x-www-form-urlencoded..Content-Length: 32..Cookie:
PD-ID=tLOwtT78DZmVixxWcgm0Nerhj5REgPMX8-1i+bJ74oY8x8dI68pFpR7z7g78sVoQJH
d60qnUWMYj+DeSB4iepSrap0NwcuaJtSWUQ7fhWV3syh8NxV4CnK1SVx2UPvBFAksTGPaUJs
I=....
Hopefully this helps track down this issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception or a normal IO exception or unknown host should result depending on the situation that is occurring. As initial connections succeeded, the host can't be null exception should never occur.
ACTUAL -
host can't be null NPE is thrown by the SecurityManager.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "HttpMC R/W 1" java.lang.NullPointerException: host can't be null
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.proxiedConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
at java.net.URLConnection.getHeaderFieldInt(Unknown Source)
at java.net.URLConnection.getContentLength(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentLength(Unknown Source)
at <our application code below>
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Catching the NPE and retrying the connection may work around the issue.