Skip to content

Commit

Permalink
Fix intermittent test failure spotted during some refactoring.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.5.x/trunk@1774166 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Dec 14, 2016
1 parent a20d11e commit 9601a93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions java/org/apache/coyote/http11/Http11InputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,16 @@ void recycle() {
void nextRequest() {
request.recycle();

// Copy leftover bytes to the beginning of the buffer
if (byteBuffer.remaining() > 0 && byteBuffer.position() > 0) {
byteBuffer.compact();
if (byteBuffer.position() > 0) {
if (byteBuffer.remaining() > 0) {
// Copy leftover bytes to the beginning of the buffer
byteBuffer.compact();
byteBuffer.flip();
} else {
// Reset position and limit to 0
byteBuffer.position(0).limit(0);
}
}
// Always reset pos to zero
byteBuffer.limit(byteBuffer.limit() - byteBuffer.position()).position(0);

// Recycle filters
for (int i = 0; i <= lastActiveFilter; i++) {
Expand Down
5 changes: 5 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
when configured with an address of <code>0.0.0.0</code> or
<code>::</code>. (markt)
</fix>
<fix>
Correct a regression in the refactoring to make wider use of
<code>ByteBuffer</code> that caused an intermittent failure in the unit
tests. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Web Applications">
Expand Down

0 comments on commit 9601a93

Please sign in to comment.