Skip to content

test: verify stream transformer cleanup on failure - #1659

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/transformer-failure-cleanup
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/transformer-failure-cleanup

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 26, 2026

Copy link
Copy Markdown
Member

Motivation

The byte-string transformer tests already cover normal completion and cancellation, but not a failure in the transformation itself.

Modification

Add one in-process test. The transformer emits the first element and throws a local test exception on the next. Assert that the sink receives the same exception. After all stages have stopped, assert that cleanup ran exactly once.

Result

Protect failure propagation and resource cleanup without changing production code.

Tests

  • JDK 17: all three focused StreamUtilsSpec transformer tests passed on Scala 2.13.18 and 3.3.9.
  • Scoped OrganizeImports, Scala formatting, license headers and whitespace checks passed locally. Full hosted CI was not run as part of this validation.

References

Refs #1142, #1154.

Motivation:
The byte-string transformer tests cover normal completion and
cancellation, but not a failure in the transformation itself.

Modification:
Exercise an in-process transformation that succeeds for one element and
then throws. Check the original error at the sink and count cleanup
after the stream has stopped.

Result:
Protect failure propagation and exactly-once resource cleanup without
changing production code.

Tests:
- JDK 17, Scala 2.13.18 and 3.3.9: the three byteStringTransformer
  tests in StreamUtilsSpec passed on each version.
- Scoped OrganizeImports, Scala formatting, license header and
  whitespace checks passed.

References:
Refs apache#1142, apache#1154.
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 09:05

@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.

Fine. Nit: the import block is reordered beyond the two imports actually needed — minor churn.

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