[#4796] Resolve the reset converter only when there is a reset context - #4806
Open
schananas wants to merge 1 commit into
Open
[#4796] Resolve the reset converter only when there is a reset context#4806schananas wants to merge 1 commit into
schananas wants to merge 1 commit into
Conversation
schananas
requested review from
MateuszNaKodach,
hjohn and
zambrovski
and removed request for
a team
July 29, 2026 11:30
`resetTokens()` resolved a `GeneralConverter` from the processing context unconditionally, once per segment, so a processor whose unit-of-work factory supplies no components could not be reset at all -- and failed with an error naming neither resets nor converters. The converter is now resolved once, and only when a reset context actually needs converting, so the no-context reset needs no components and a genuine missing-converter failure surfaces once instead of once per segment. Fixes #4796
schananas
force-pushed
the
bug/4796/reset-tokens-no-converter-when-no-context
branch
from
July 29, 2026 18:09
30e215e to
a3517ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4796
What changed
resetTokens()resolved aGeneralConverterfrom the processing context unconditionally, once per segment, so a processor whose unit-of-work factory supplies no components could not be reset at all. It failed withUnsupportedOperationException: EmptyApplicationContext does not provide any components, an error naming neither resets nor converters.The converter is now resolved once, and only when a reset context actually needs converting.
convertedResetContextreturns an empty array immediately for anullreset context, and the resultingbyte[]is computed once infetchSegmentsWithTokensand passed down.Tests
New:
PooledStreamingEventProcessorTest.ResetSupportTest.resetTokensWithoutResetContextDoesNotRequireAConverter, usingSimpleUnitOfWorkFactory(EmptyApplicationContext.INSTANCE). It fails on unfixed code with the exception above. Fullmessagingmodule: green.For the reviewer
Two effects of one change. Hoisting the conversion out of the per-segment lambda means a genuine missing-converter failure now surfaces once per reset instead of once per segment. Short-circuiting on a null reset context means the component lookup never happens at all for the common
resetTokens()case.fetchTokenForSegmentconsequently loses its<R>type parameter and takes the already-convertedbyte[].For a reset that carries a context the produced bytes are unchanged: every in-tree converter returns null for a null input, so the old
null ? new byte[0]produced exactly what the short-circuit produces.One behaviour does change, on zero initialized segments. Because the conversion moved ahead of
fetchSegments, it now runs even when the per-segment lambda never would. A context-carrying reset on a processor whose tokens were never initialized used to succeed and invoke reset handlers; it now fails. Generalises to anyConversionExceptionon an unserializable context with zero segments. Fail-fast is the better behaviour -- a reset that cannot serialize its context should not report success -- but it is a change, not a no-op.Second effect: one
byte[]instance is now shared by every segment'sReplayToken. Bytes are equal, so equality, storage and serialization are unaffected, butReplayToken.resetContext():352hands out the internal array, so a caller mutating it perturbs every segment's token in that reset rather than one. Pre-existing leak, newly wider; no mutation site exists in the tree.