JDK-4222009 : file not found template is shown instead of host not found reply
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-03-19
  • Updated: 2000-09-08
  • Resolved: 2000-09-08
Related Reports
Duplicate :  
Description

Name: vlC75247			Date: 03/19/99


Ensure that proxy is correctly set.
Try to load  for example http://badhost.com/.
This host doesn't exist and "host not found" proxy reply will be shown.
Try to load http://badhost.com/filename .
Notice that template "File not found" will be shown, whish  says that 
/filename could not be located on host badhost.com.   

======================================================================

Comments
EVALUATION This is not ours. Here is the test program, that acts like HotJava: --- cut --- import java.net.*; import java.io.*; import java.util.Properties; public class RetrHttp { RetrHttp(String urlString) { URL url=null; InputStream io; try { URL.setURLStreamHandlerFactory(new MyFactory()); } catch (Exception e) { System.err.println("Factory is already installed!"); System.exit(0); } Properties props = System.getProperties(); props.put("http.proxyHost","guard"); props.put("http.proxyPort","3128"); props.put("trustProxy", "true"); try { url = new URL(urlString); } catch (MalformedURLException e) { System.err.println("Malformed URL"); System.exit(0); } try { URLConnection conn = url.openConnection(); conn.connect(); io = conn.getInputStream(); } catch (Exception e) { e.printStackTrace(); System.exit(0); } System.out.println("Everything is OK!"); } public static void main(String arg[]) { if (arg.length < 1) { System.err.println("Usage : java RetrHttp <url>"); System.exit(0); } new RetrHttp(arg[0]); } class MyFactory implements URLStreamHandlerFactory { public URLStreamHandler createURLStreamHandler(String protocol) { System.out.println("Asked for Handler for proto "+protocol); if (protocol.equalsIgnoreCase("http")) { return new sun.net.www.protocol.http.Handler (); } else { return null; } } } } --- cut --- Here are test results : [vps@druid]~/jprogs$ java RetrHttp http://bad Asked for Handler for proto http Everything is OK! [vps@druid]~/jprogs$ java RetrHttp http://bad/name Asked for Handler for proto http java.io.FileNotFoundException: http://bad/name at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:477) at RetrHttp.<init>(RetrHttp.java:35) at RetrHttp.main(RetrHttp.java:50) [vps@druid]~/jprogs$ java RetrHttp http://bad/name.html Asked for Handler for proto http Everything is OK! [vps@druid]~/jprogs$ So, jdk is somewhy generate the exception about bad host instead of redirecting this request to proxy server. I think this should be addressed to java.java_net or sun_net [sub]cathegory. ###@###.### 1999-03-19 The problem occurs in getInputStream in class HttpURLConnection. In the current implementation, whenever the response code is greater than and equal to 400 etc, we will throw FileNotFoundException. But if for instance, the response code is 5xx, it would indicate a server side error. In the case of having a nonexistent hostname and using a proxy server, the response code is 500. The following is the log of a telnet session that shows this: telnet webcache-cup 8080 Trying 129.144.170.48... Connected to webcache-cup. Escape character is '^]'. GET http://yingxianhost/bad HTTP/1.1 HTTP/1.0 500 Error from proxy Mime-version: 1.0 Proxy-agent: Netscape-Proxy/3.51 Content-type: text/html <HTML> <HEAD><TITLE>Error</TITLE></HEAD> <BODY> <H1>Error</H1> <BLOCKQUOTE><B> <HR SIZE=4><P> The requested item could not be loaded by the proxy.<P> Netscape Proxy is unable to locate the server: yingxianhost The server does not have a DNS entry. Check the server name in the Location (URL) and try again.<P> <HR SIZE=4> </B></BLOCKQUOTE> <P> <ADDRESS>Proxy server at saturn5.EBay.Sun.COM on port 8080</ADDRESS> </BODY></HTML> Connection closed by foreign host. We are working on a fix. yingxian.wang@eng 1999-06-30 Since the fix for this bug is considered too risky for kestrel after beta, and the payoff is too low in comparison. We will commit the fix for Merlin. yingxian.wang@eng 1999-09-20 Related to bug 4160499. We should get rid of the error handling inside HttpURLConnection.getInputStream, and let applications rely on response code and message for further action. As it should have been done in the first place. yingxian.wang@eng 1999-10-11
11-10-1999