JDK-5049976 : Unspecified NPE is thrown when streaming output mode is enabled
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-05-19
  • Updated: 2004-06-08
  • Resolved: 2004-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b55Fixed
Related Reports
Relates :  
Description

Name: vpR10197			Date: 05/19/2004


--------------------------------------                                                                                   
Test        : http/HttpStreaming/Chunked/chunked001
VM          : ClientVM, ServerVM
Mode        : all
Platform    : all
OS          : all
JDK         : since tiger-b50
----------------------------------------                                                                                 
The test checks up HttpURLConnection.setChunkedStreamingMode() method,
for dummy HTTP server which implements no request method.
According to the specification of the URLConnection.getInputStream method,
IOException must be thrown when a request method is not implemented by HTTP
server (I beleive it is a case when input stream can not be created).
Indeed, IOException is thrown when no streaming mode is not set, but
if some streaming mode is enabled via setChunkedStreamingMode() or
setFixedLengthStreamingMode(), getInputStream() throws NullPointerException
that contradicts spec.

To reproduce the failure:
   cd /net/jano.sfbay/export/disk20/GammaBase/Bugs/<this bug number>
   sh run.sh $JAVA_HOME [-g] [JAVA_OPTS]
where
     -g  - run test with java_g binaries

Here is an example of test's output:
    Settings:
    >Starting default Http-server
    Server started
    java.lang.NullPointerException
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:823)
            at chunked001.main(chunked001.java:53)
    ***ERR***>UNEXPECTED exception: java.lang.NullPointerException
    TEST FAILED
    Java exit code: 97

But if calling setChunkedStreamingMode would be commented (line 49 of
chunked001.java) then output would be:
    Settings:
    >Starting default Http-server
    Server started
    HTTP version: HTTP/1.1
    java.io.IOException: Server returned HTTP response code: 501 for URL: http://localhost:8080
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1066)
            at chunked001.main(chunked001.java:53)
    Expected exception: java.io.IOException: Server returned HTTP response code: 501 for URL: http://localhost:8080
    TEST PASSED
    Java exit code: 95

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-rc FIXED IN: tiger-rc INTEGRATED IN: tiger-b55 tiger-rc
08-07-2004

SUGGESTED FIX 821c821 < if (streaming() ) { --- > if (streaming() && strOutputStream != null ) {
08-07-2004

EVALUATION The problem happens when streaming output is enabled, but the application does not call getOutputStream() to actually do the output. The details of the server are not actually relevant. ie. this problem will occur with any webserver, which makes the impact more severe unfortunately. We should fix this for tiger, since it is low risk, and the bug is rather ugly. ###@###.### 2004-05-20
20-05-2004