Name: nt126004 Date: 02/04/2002
FULL PRODUCT VERSION :
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
FULL OPERATING SYSTEM VERSION :
System = SunOS
Node = bandit
Release = 5.7
KernelID = Generic_106541-14
Machine = sun4u
BusType = <unknown>
Serial = <unknown>
Users = <unknown>
OEM# = 0
Origin# = 1
NumCPU = 2
ADDITIONAL OPERATING SYSTEMS :
System = SunOS
Node = chaos.ericsson.net.nz
Release = 5.8
KernelID = Generic_108528-05
Machine = sun4u
BusType = <unknown>
Serial = <unknown>
Users = <unknown>
OEM# = 0
Origin# = 1
NumCPU = 1
A DESCRIPTION OF THE PROBLEM :
if System.getProperties().put("proxySet", "false") is called
after proxy details have been set, then
HttpURLConnection.geyOutputStream times out. It seems to
ignore proxySet=false.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Start something listening on a port on the local host,
e.g. using netcat "nc -l -p 10090"
2. Run the sample code, with the FQDN for local host
specifying the correct port in the URL.
java ProxyTest http://myhost.myorg.com:10090/somepath false
my.local.proxy 80
3.the client does not get the connection, it seems still go
via the proxy server event through proxySet=false.
4. Try the command (2) again but without the proxy details.
e.g. java ProxyTest http://myhost.myorg.com:10090/somepath
EXPECTED VERSUS ACTUAL BEHAVIOR :
That
{
System.getProperties().put("proxySet", "false");
System.getProperties().put("proxyHost", "proxy.myorg.com");
System.getProperties().put("proxyPort", "80");
}
be the same as not setting proxy* at all
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;
import java.util.Properties;
public class ProxyTest {
public static void main (String args[]) {
if (args.length == 0) {
System.out.println("need to provide a URL and [proxySet [proxyHost
[proxyPort]]]");
System.exit(0);
}
String requestedUrl = args[0];
if (args.length > 1) {
System.getProperties().put("proxySet", args[1]);
}
if (args.length > 2) {
System.getProperties().put("proxyHost", args[2]);
}
if (args.length > 3) {
System.getProperties().put("proxyPort", args[3]);
}
ProxyTest sender = new ProxyTest();
System.out.println(sender.fetch(requestedUrl, "post=some+data"));
}
public String fetch (String urlString, String postInfo ) {
// open connection
URL url = null;
HttpURLConnection con = null;
try {
url = new URL(urlString);
con = (HttpURLConnection)url.openConnection();
if (postInfo != null) {
con.setRequestMethod("POST");
} else {
con.setRequestMethod("GET");
con.setDoInput(true);
}
} catch (MalformedURLException murle) {
System.err.println(murle.toString());
return null;
} catch (ProtocolException pe) {
System.err.println(pe.toString());
return null;
} catch (IOException ioe) {
System.err.println(ioe.toString());
return null;
}
// do the post stuff
if (postInfo != null) {
try {
con.setDoOutput(true);
OutputStream os = con.getOutputStream();
PrintWriter out = new PrintWriter(os);
out.print(postInfo);
out.close();
} catch (IOException ioe) {
System.err.println(ioe.toString());
}
}
// get the connection for the response.
BufferedReader fromServer = null;
try {
fromServer = new BufferedReader( new
InputStreamReader(con.getInputStream()));
} catch (IOException ioe) {
System.err.println("IOE:" + ioe.toString());
return null;
}
// read in the response
StringBuffer sb = new StringBuffer();
int inChars = 0;
String inLine;
try {
while ( (inLine = fromServer.readLine()) != null) {
sb.append(inLine);
}
fromServer.close();
} catch (IOException ioe) {
System.err.println("IOE:" + ioe.toString());
return null;
}
// return the response to the caller
return sb.toString();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Setting the proxyHost & Port to an empty string seems to work.
System.getProperties().put("proxyHost", "");
(Review ID: 138688)
======================================================================