You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2013/02/24 09:07:07 UTC

[Bug 54604] New: NPE at InternalInputBuffer.java while using AsyncContext

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: speaktovpr@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54604] NPE at InternalInputBuffer.java while using AsyncContext

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

Prakasaraman.V <sp...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P1
                 OS|                            |All

--- Comment #1 from Prakasaraman.V <sp...@gmail.com> ---
Hi Tomcat Team,

It would be really helpful if somebody can respond to my below issue.

This is a CRITICAL problem for us as it is affecting our CUSTOMER PRODUCTION
setups.

Thanks & Regards,
Prakasaraman.V

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

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


[Bug 54604] NPE at InternalInputBuffer.java while using AsyncContext

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Mark Thomas <ma...@apache.org> ---
There is no bug to fix here. The supported (by the Tomcat community) option is
to upgrade your Tomcat instance. If you want to do something else then the
users list is the place to seek further assistance.

As a pointer to get you started:
- test the Tomcat instances between 7.0.21 and 7.0.29 to narrow down the search
for this particular fix
- review the chnagelog for the version with the fix
- if nothing in the change log strikes you as async related you could review
the diff between the tag that works and the tag that doesn't
- finally you can do a binary search for the revision with the fix by building
Tomcat from a specific svn revision using the revisions for the tags as the
upper and lower limits to start with

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

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


[Bug 54604] NPE at InternalInputBuffer.java while using AsyncContext

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

Prakasaraman.V <sp...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #4 from Prakasaraman.V <sp...@gmail.com> ---
Hi Mark Thomas,

Thanks for your guidance. I have tried with asyncContext.setTimeout(0). This is
working fine with Tomcat 7.0.29 but it fails in Tomcat 7.0.21.

In Tomcat 7.0.21, I am getting the below mentioned SocketTimeoutException.
Since this is working fine in Tomcat 7.0.29, I assume there should be a change
in source with respect to this issue in one of the Tomcat 7.0.21 post releases.
Could you help me to locate the exact fix (source changes) for this issue so
that I can make it on top of 7.0.21 source.

java.net.SocketTimeoutException
    at
org.apache.tomcat.util.net.NioBlockingSelector.read(NioBlockingSelector.java:189)
    at
org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:228)
    at
org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:209)
    at
org.apache.coyote.http11.InternalNioInputBuffer.readSocket(InternalNioInputBuffer.java:403)
    at
org.apache.coyote.http11.InternalNioInputBuffer.fill(InternalNioInputBuffer.java:759)
    at
org.apache.coyote.http11.InternalNioInputBuffer$SocketInputBuffer.doRead(InternalNioInputBuffer.java:784)
    at
org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:118)
    at
org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:331)
    at org.apache.coyote.Request.doRead(Request.java:422)
    at
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:287)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:407)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:310)
    at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:202)
    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:83)
    at test.TestAsyncFilter.access$0(TestAsyncFilter.java:67)
    at test.TestAsyncFilter$1.run(TestAsyncFilter.java:54)
    at
org.apache.catalina.core.AsyncContextImpl$RunnableWrapper.run(AsyncContextImpl.java:472)
    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)

Thanks & Regards,
Prakasaraman.V

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

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


[Bug 54604] NPE at InternalInputBuffer.java while using AsyncContext

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Mark Thomas <ma...@apache.org> ---
The async request has timed out.

Once startAsync() has been called, dispatch() or complete() must be called
before the timeout expires. In this case your requets processing is taking
longer than the timeout. The NPE is the result of continuing to use the request
after the async timeout has expired.

You need to use a larger timeout.

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

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


[Bug 54604] NPE at InternalInputBuffer.java while using AsyncContext

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54604

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Common                      |Connectors
            Version|unspecified                 |7.0.29
            Product|Tomcat Connectors           |Tomcat 7

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Correct the product

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

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