Skip to content

Backport: Fix byte string transformer cleanup on stage stop (1.4.x)#1155

Merged
He-Pin merged 1 commit into
apache:1.4.xfrom
He-Pin:backport/fix-byte-string-transformer-cleanup-1.4
Jul 11, 2026
Merged

Backport: Fix byte string transformer cleanup on stage stop (1.4.x)#1155
He-Pin merged 1 commit into
apache:1.4.xfrom
He-Pin:backport/fix-byte-string-transformer-cleanup-1.4

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 11, 2026

Copy link
Copy Markdown
Member

Motivation

Backport of #1154 to the 1.4.x branch.

On the byte-string transformer, finished was set before the pending final emission was delivered. If downstream cancelled in that window, postStop skipped cleanup, leaking transformer resources.

Modification

Cherry-pick of commit 18796ca from main:

  • Treat cleanup as the stage finalizer by invoking it unconditionally from postStop.
  • Drop the fragile finished flag.
  • Add directional tests for normal completion and for cancellation while the final emission is pending.

Existing compressor cleanup is idempotent, so the unconditional call is safe.

Result

All stage termination paths release transformer resources on 1.4.x without relying on a fragile finished flag.

Tests

  • Delegated to CI for the 1.4.x branch (mirrors validation already done on main in Ensure byte string transformers clean up on every stage stop #1154).
  • On main: sbt "http-core / Test / testOnly org.apache.pekko.http.impl.util.StreamUtilsSpec" (7 passed), sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.coding.DeflateSpec org.apache.pekko.http.scaladsl.coding.GzipSpec" (54 passed), sbt checkCodeStyle, sbt headerCreateAll/+headerCheckAll, and scalafmt --list --mode diff-ref=origin/main all passed.

References

Motivation:
A byte string transformer marked itself finished before a pending final emission was delivered, so downstream cancellation in that window skipped cleanup.

Modification:
Treat cleanup as the stage finalizer by invoking it unconditionally from postStop, and add directional tests for normal completion and cancellation while the final emission is pending.

Result:
All stage termination paths release transformer resources without relying on a fragile finished flag. Existing compressor cleanup remains safe because it is idempotent.

Tests:
- sbt "http-core / Test / testOnly org.apache.pekko.http.impl.util.StreamUtilsSpec": 7 passed
- sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.coding.DeflateSpec org.apache.pekko.http.scaladsl.coding.GzipSpec": 54 passed
- sbt checkCodeStyle: passed
- sbt headerCreateAll and +headerCheckAll: passed
- scalafmt --list --mode diff-ref=origin/main: passed
- sbt sortImports: environment failure, Scalafix/scala.meta NoSuchMethodError
- sbt validatePullRequest: not run locally per maintainer request; delegated to CI

References:
Refs apache#1133; follow-up to apache#1142
@He-Pin He-Pin requested a review from pjfanning July 11, 2026 11:38

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@He-Pin He-Pin merged commit 21a46f5 into apache:1.4.x Jul 11, 2026
10 checks passed
@He-Pin He-Pin deleted the backport/fix-byte-string-transformer-cleanup-1.4 branch July 11, 2026 12:23
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