Skip to content

BrotliEncoder: Prevent duplicate close scheduling (#17175) - #17193

Merged
normanmaurer merged 1 commit into
4.1from
close41
Aug 3, 2026
Merged

normanmaurer merged 1 commit into
4.1from
close41

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

BrotliEncoderChannel.close() closes its destination, which re-enters BrotliEncoder.Writer.close(). The re-entrant call schedules another finish task before isClosed is set. If the first finish fails, the second task can retry with an already-failed close promise.

Modification:

Track whether writer close has already been initiated and ignore subsequent close calls before scheduling another finish task.

Result:

Brotli encoder close is idempotent while a finish is pending, and exceptional finalization no longer retries with an already-completed promise.

Motivation:

`BrotliEncoderChannel.close()` closes its destination, which re-enters
`BrotliEncoder.Writer.close()`. The re-entrant call schedules another
finish task before `isClosed` is set. If the first finish fails, the
second task can retry with an already-failed close promise.

Modification:

Track whether writer close has already been initiated and ignore
subsequent close calls before scheduling another finish task.

Result:

Brotli encoder close is idempotent while a finish is pending, and
exceptional finalization no longer retries with an already-completed
promise.

Co-authored-by: multicode <[email protected]>
@normanmaurer normanmaurer added this to the 4.1.137.Final milestone Aug 3, 2026
@normanmaurer
normanmaurer merged commit f4f1b9d into 4.1 Aug 3, 2026
17 of 18 checks passed
@normanmaurer
normanmaurer deleted the close41 branch August 3, 2026 12:58
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
…y#17193)

Motivation:

`BrotliEncoderChannel.close()` closes its destination, which re-enters
`BrotliEncoder.Writer.close()`. The re-entrant call schedules another
finish task before `isClosed` is set. If the first finish fails, the
second task can retry with an already-failed close promise.

Modification:

Track whether writer close has already been initiated and ignore
subsequent close calls before scheduling another finish task.

Result:

Brotli encoder close is idempotent while a finish is pending, and
exceptional finalization no longer retries with an already-completed
promise.

Co-authored-by: Jonas Konrad <[email protected]>
Co-authored-by: multicode <[email protected]>
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