https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

            Bug ID: 54604
           Summary: NPE at InternalInputBuffer.java while using
                    AsyncContext
           Product: Tomcat Connectors
           Version: unspecified
          Hardware: All
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Common
          Assignee: dev@tomcat.apache.org
          Reporter: speakto...@gmail.com
    Classification: Unclassified

Hi Friend,

I am getting following NPE, while I am using AsyncContext in the below
mentioned scenario.

Scenario :
I have introduced 1 sec delay inside the while loop after every readLine() call
from BufferedReader. This is causing the below error. Please note that, it is
working fine if I am not using AsyncContext with the same read delay value( 1
sec). Hence I am suspecting this problem is related to AsyncContext. 

Server side code snippet in my servlet is shown below :
...........................................................
AsyncContext ctx = request.startAsync();
BufferedReader br = new BufferedReader(new
InputStreamReader(ctx.getRequest().getInputStream()));
String line=null;

while((line= br.readLine())!=null) 
        {    

                System.out.println(line);
Thread.sleep(1000);

    }
...........................................................

Client side code snippet to send 50 MB of data in a HttpPost request            
.............................................................
org.apache.commons.httpclient.HttpClient client = new
org.apache.commons.httpclient.HttpClient();

String fileName = "F:\\SampleFile_50MBData";
FileInputStream is= new FileInputStream(fileName);
PostMethod postMethod = new
PostMethod("http://localhost:8080/async-read-delay/test";);
postMethod.setRequestEntity(new InputStreamRequestEntity(is,-1));
int response = client.executeMethod(postMethod);
is.close();    
.............................................................

Exception in thread "http-bio-8080-exec-2" java.lang.NullPointerException
    at
org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:516)
    at
org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)
    at
org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:563)
    at
org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:344)
    at org.apache.coyote.Request.doRead(Request.java:422)
    at
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:431)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315)
    at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200)
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at test.TestAsyncFilter.readContent(TestAsyncFilter.java:82)
    at test.TestAsyncFilter.access$0(TestAsyncFilter.java:66)
    at test.TestAsyncFilter$1.run(TestAsyncFilter.java:53)
    at
org.apache.catalina.core.AsyncContextImpl$RunnableWrapper.run(AsyncContextImpl.java:474)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


Note : I have tested this in Tomcat 7.0.29. Also the same issue is seen since
Tomcat 7.0.21. if I remove the time delay of 1 sec, it is working fine.

Let me know, if there is any fix is available for this problem.

Regards,
Prakasaraman.V

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to