JDK-4492994 : HttpURLConnection generates erroneous FileNotFoundException if respCode >=400
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.3.1
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2001-08-16
  • Updated: 2001-08-17
  • Resolved: 2001-08-17
Related Reports
Duplicate :  
Description
The method getResponseCode() in HttpURLConnection calls
it's getInputStream() method, which extracts the response code
from the HTTP response.  According to the API doc, and common
sense, it should return the response code specified by the server
in the HTTP response.  But when the response code specified is
>=400, it does not return the code, instead it throws a FileNotFoundException.
This is totally misleading, because the URL was indeed found, and generated
a valid error response, which is thrown away by HttpURLConnection, so the
client can never see it, or handle it.  This behavior is completely
inappropriate.

It is true that HttpURLConnection does not generate the FileNotFoundException
if the URL in question ends in ".htm", "/", or ".txt", but the point is,
that it should NEVER throw a FileNotFoundException if it gets a response
from the server for the given URL, no matter what the URL is or what the
response is.

Comments
EVALUATION Also fixed in merlin - see 4160499. ###@###.### 2001-08-17
17-08-2001