Repository navigation
feat(common-json): mark and rewind the generator - #3214
Merged
Merged
Conversation
A generator can mark its position between writes and rewind to it, which discards the bytes written since and restores the structural context, so a unit of output can be generated, measured and then kept or taken back and generated again. This is the output-side counterpart of the parser mark and rewind. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ
…wind The generator mark and rewind are declared without a default, as JsonGeneratorImpl is the one implementation of JsonGeneratorEx and supports both. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ
jfallows
added a commit
that referenced
this pull request
Nov 14, 2026
… per-filter suback failure (#3231) * feat(common-json): mark and rewind the generator (#3214) * feat(common-json): mark and rewind the generator A generator can mark its position between writes and rewind to it, which discards the bytes written since and restores the structural context, so a unit of output can be generated, measured and then kept or taken back and generated again. This is the output-side counterpart of the parser mark and rewind. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ * refactor(common-json): require every generator to support mark and rewind The generator mark and rewind are declared without a default, as JsonGeneratorImpl is the one implementation of JsonGeneratorEx and supports both. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ * test(common-json): rewind the generator that escapes its output Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ --------- Co-authored-by: Claude <[email protected]> * test(binding-mqtt-kafka): specify per-filter suback failure for a filter no route matches Failing scripts and ITs only, ahead of the production change for #3208: mqtt-kafka echoes the stored session state with reasonCode 0x80 on each filter no subscribe route matches, and the mqtt binding leaves such a filter out of its session state and skips it on resume. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW6JiEUeLJ93BQKGfQ * test(binding-mqtt): carry the subscription flags of the unsubscribe-after-failed-filter scenario The application scripts of subscribe.topic.filters.non.successful.unsubscribe are shared by the v4 and v5 ITs, and a v3.1.1 SUBSCRIBE always requests the retained messages to be sent, so the state they expect must carry the SEND_RETAINED flag in both versions. Adds the session state builder that sets the qos, flags and reason code of a filter together. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW6JiEUeLJ93BQKGfQ * fix(binding-mqtt-kafka): answer a filter that no route matches with a per-filter suback failure The session factory marks each filter of the session state it echoes to the mqtt binding, on a SUBSCRIBE and when the stored state is delivered at CONNECT, with reason code 0x80 when no subscribe route authorized for the session matches it. The mqtt binding carries the code into the SUBACK, opens no subscribe stream for the filter, leaves it out of its session state and skips it on resume, so the connection stays open and the other filters of the SUBSCRIBE are delivered as usual. Nothing new is persisted. Fixes #3208 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW6JiEUeLJ93BQKGfQ --------- Co-authored-by: Claude <[email protected]>
jfallows
added a commit
that referenced
this pull request
Nov 15, 2026
…own broker id (#3232) * feat(common-json): mark and rewind the generator (#3214) * feat(common-json): mark and rewind the generator A generator can mark its position between writes and rewind to it, which discards the bytes written since and restores the structural context, so a unit of output can be generated, measured and then kept or taken back and generated again. This is the output-side counterpart of the parser mark and rewind. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ * refactor(common-json): require every generator to support mark and rewind The generator mark and rewind are declared without a default, as JsonGeneratorImpl is the one implementation of JsonGeneratorEx and supports both. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ * test(common-json): rewind the generator that escapes its output Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ --------- Co-authored-by: Claude <[email protected]> * test(binding-kafka): script the refresh before an unknown broker id is answered A raw API request stream addressed to a non-zero broker id that the route's table does not know triggers an immediate Metadata refresh, and is answered with the existing reset only after that refresh has completed or failed. There is no retry, even when the refreshed table now contains the id. The network scripts for the unknown id now play a second Metadata exchange before the reset. New paired scripts cover a refresh whose response lists the id (still reset, no connection to that broker) and a refresh that fails (the meta connection is aborted). The application pairs for the same two scenarios carry the refreshed partitions on the meta stream. The spec network and application ITs and the runtime IT gain one method per scenario. The runtime scenarios fail against the current binding because it never sends the second Metadata request. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVZT5Lb5aAUG57ioRa * fix(binding-kafka): refresh the broker table before answering an unknown broker id A raw API request stream addressed to a non-zero broker id that the route's table does not know is no longer reset at once. It is held, the route's Metadata refresh is triggered (the same metaFlush the fetch and produce clients use), and the stream is reset with the existing reset only after that refresh has completed or failed. There is no retry, so the answer to that attempt is the reset even if the refreshed table now has the id, and the caller's next request meets a fresh table. KafkaClientRoute gains the reverse of its meta flush registry: a one-shot completion callback that the meta client fires after a Metadata response has rewritten the table and when its stream fails. Streams hitting the same unknown id share one flush and are reset together; a route with no meta stream resets at once. The same holds when a reconnect finds the id gone. An unknown id gets no entry in clientsByAffinity. Fixes #3213 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVZT5Lb5aAUG57ioRa --------- Co-authored-by: Claude <[email protected]>
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.
Description
Adds
mark()andrewind()toJsonGeneratorEx, the output-side counterpart of the parser'smark()andrewind().A generator can mark its position between writes and rewind to it. Rewinding discards the bytes written since the mark and restores the structural context: open object and array depth, the separator state of each open level, an open string or number fragment, the open escaped scopes, and
length(),remaining()andconsumed(). A unit of output can therefore be generated and measured, then either kept or taken back and generated again.Contract, mirroring the parser:
wraporreset, andrewind()throwsIllegalStateExceptionotherwiseJsonGeneratorImplis the one implementation ofJsonGeneratorExand supports bothTests (
JsonGeneratorMarkRewindTest):length(),remaining()andconsumed()are restoredwraporreset, is refusedVerification:
./mvnw clean install -pl runtime/common-jsonpasses (5245 tests, 0 failures).No issue was opened first, as this is a small, additive API change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoUTvQwZM7nY1gjgnZJ