Menu

#2 SpnegoHttpURLConnection.getErrorStream() does not return err

open
nobody
None
5
2018-11-19
2012-01-31
Anonymous
No

SpnegoHttpURLConnection provides method

public InputStream getErrorStream() throws IOException {
assertConnected();

return this.conn.getInputStream();
}

it does not return ErrorStream as you see.

Discussion

  • Darwin Felix

    Darwin Felix - 2012-01-31

    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4160499

    http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/net/HttpURLConnection.java.html#line.503

    Based on the above links, it appears that the JDK is hard-coded to return null...?

    What do you think about changing it to something like this...

    // hard-coded to return null by JDK
    final InputStream is = this.conn.getErrorStream();

    if (null != is) {
    return is;
    } else {
    return this.conn.getInputSream();
    }

    The idea is that you can force the API user to check if there was an error via the http status code (vs null check on getErrorStream).

    Hence, if status code indicates an error, then the API user may call getErrorStream. But since the JDK is hard-coded to return null, it might be helpful to the API user if we returned the getInputStream instead...?

    What do yo think?

     
  • Sebastian Wolff

    Sebastian Wolff - 2018-11-19

    Hello,

    I just stumbled upon this error myself. Is this ever going to be fixed? This bug report is already 6 years old. It would be great to be able to read the response of web-services in the case of an error. Otherwise, as it is currently implemented, there is no way to narrow down the error in most cases. I currently have to painstakingly simulate my requests with other tools to get accurate error messages.

    Best Regards,
    Sebastian

     

Log in to post a comment.