Bug 56296 - AjpNioProcessor throws java.nio.BufferOverflowException
Summary: AjpNioProcessor throws java.nio.BufferOverflowException
Status: RESOLVED DUPLICATE of bug 53119
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.52
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-21 09:57 UTC by hugo.lumsdon
Modified: 2014-03-23 22:58 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hugo.lumsdon 2014-03-21 09:57:15 UTC
We are seeing the following sporadic exceptions in catalina.out:

Mar 21, 2014 2:42:13 AM org.apache.coyote.ajp.AjpNioProcessor process
SEVERE: Error processing request
java.nio.BufferOverflowException
        at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:183)
        at org.apache.coyote.ajp.AjpNioProcessor.output(AjpNioProcessor.java:296)
        at org.apache.coyote.ajp.AbstractAjpProcessor$SocketOutputBuffer.doWrite(AbstractAjpProcessor.java:1195)
        at org.apache.coyote.Response.doWrite(Response.java:520)
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:408)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
        at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:359)
        at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:309)
        at org.apache.catalina.connector.Response.finishResponse(Response.java:510)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:435)
        at org.apache.coyote.ajp.AjpNioProcessor.process(AjpNioProcessor.java:177)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1721)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744


We have correlated these with the following error in our application log:

2014-03-21 02:42:13,753 (tomcat-exec-13) ERROR [xxxxx.StreamingManagerImpl] Error streaming document [/xxxxxxx/responsible-investment-report-2011.pdf]
ClientAbortException:  java.io.IOException: Broken pipe
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:413)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366)
        at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:438)
        at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:426)
        at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:91)
        at org.apache.catalina.servlets.DefaultServlet.copyRange(DefaultServlet.java:2032)
        at org.apache.catalina.servlets.DefaultServlet.copy(DefaultServlet.java:1871)
        at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:959)
        at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:409)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)



We want to understand whether the error is benign and simply caused by a client dropping connection mid-download.  Or if it's the other way round - for example a slow network download speed to the client causes the buffer overflow and the connection drop.
Comment 1 Mark Thomas 2014-03-23 22:08:25 UTC
The trigger for this series of stack traces is the java.io.IOException: Broken pipe which normally indicates that the client has dropped the connection or a network issue that looks like the client has dropped the connection.

The initial error causes a write to fail and as a result the buffer is not cleared (it should be). The next attempt to write therefore fails because the buffer has not been cleared.

I'll see what I can do to fix this.
Comment 2 Mark Thomas 2014-03-23 22:58:55 UTC
I've back-ported the AJP NIO fix to 7.0.x and it will be included in 7.0.53 onwards.

*** This bug has been marked as a duplicate of bug 53119 ***