Regarding review of r1344253 and porting it to other processor implementations
http://tomcat.markmail.org/thread/d4mzx52gj3omchrr
The question of whether repeated call to *processor#output(..) could fail because of insufficient cleanup from previous failed call.
- AjpProcessor:
There is nothing to clean up. It just uses passed byte[] array as is.
- AjpNioProcessor:
Improved in r1346365 in trunk, proposed for 7.0.

Hi,
as reported on the users list [1], shortly after I switched to the AJP-NIO connector on Tomcat 7.0.32 (Java 1.7.0_09), I got another java.nio.BufferOverflowException:
Okt 20, 2012 2:58:51 PM 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:281)
at org.apache.coyote.ajp.AbstractAjpProcessor$SocketOutputBuffer.doWrite(AbstractAjpProcessor.java:1122)
at org.apache.coyote.Response.doWrite(Response.java:504)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:383)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:462)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:334)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:283)
at org.apache.catalina.connector.Response.finishResponse(Response.java:514)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:434)
at org.apache.coyote.ajp.AjpNioProcessor.process(AjpNioProcessor.java:184)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
The stacktrace seems to be very similar to the one that I got when using the AJP-APR connector. However, unfortunately I'm currently unable to reproduce the issue that causes this BufferOverflowException.
Thanks!
[1] http://markmail.org/message/uiife6gx7zwmyfku

Is it absolutely sure that this bug is fixed? I tried to use ajp-nio with the latest 7.0.52 version and get the same problem right on the first page:
Mar 12, 2014 12:18:09 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8091"]
Mar 12, 2014 12:18:09 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8016"]
Mar 12, 2014 12:18:09 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 32142 ms
Mar 12, 2014 12:18:46 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.realWriteChars(OutputBuffer.java:491)
at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:464)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:293)
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)

Update!
We're using shibboleth for SAML authentication and they recommend that you increase the package size. We've been running with the default AJP-connector for over a year with packetSize="65536" and ProxyIOBufferSize 65536 in Apache, but when we turned that off the AjpNioProcessor works again. What is the best way to debug this problem? Should I create a new ticket?

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.