Skip to content

fix(ChunkedOutputFilter): reset position chunks buffer when recycled - #1058

Open
choijunwoo wants to merge 2 commits into
apache:mainfrom
choijunwoo:fix-checked-output-filter
Open

fix(ChunkedOutputFilter): reset position chunks buffer when recycled#1058
choijunwoo wants to merge 2 commits into
apache:mainfrom
choijunwoo:fix-checked-output-filter

Conversation

@choijunwoo

Copy link
Copy Markdown

Problem

ChunkedOutputFilter reuses the lastChunk, crlfChunk, and endChunk
ByteBuffer instances across responses.

The end() method resets these buffers only after the corresponding downstream
write completes successfully. If HttpOutputBuffer.doWrite() consumes part of a
buffer and then throws an IOException, the reset is skipped.

When the owning Http11Processor is subsequently recycled, the same
ChunkedOutputFilter may be reused with the stale buffer position. For example,
if the first two bytes (0\r) of the terminal chunk (0\r\n\r\n) were consumed
before the exception, the next response would write only the remaining
\n\r\n.

Fix

Reset the position to zero and the limit to the capacity for all reusable chunk
buffers in ChunkedOutputFilter.recycle():

  • lastChunk
  • crlfChunk
  • endChunk

This mirrors the reset already performed after successful writes while also
covering exceptional write paths.

@choijunwoo
choijunwoo force-pushed the fix-checked-output-filter branch from 0a209a0 to bc9926c Compare September 7, 2026 06:14
@choijunwoo
choijunwoo force-pushed the fix-checked-output-filter branch from bc9926c to ab0b860 Compare September 8, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants