Initial commit to refactor the OutputCodec to support a Writer per OutputStream#5606
Merged
dlvenable merged 3 commits intoApr 28, 2025
Merged
Conversation
…s bound to a specific OutputStream. This supports backward compatibility with the existing APIs and an update to the JsonOutputCodec to start the migration. Signed-off-by: David Venable <dlv@amazon.com>
kkondaka
reviewed
Apr 16, 2025
| private JsonWriter(final OutputStream outputStream, final OutputCodecContext codecContext) throws IOException { | ||
| this.outputStream = outputStream; | ||
| this.codecContext = codecContext; | ||
| generator = JSON_FACTORY.createGenerator(outputStream, JsonEncoding.UTF8); |
Collaborator
There was a problem hiding this comment.
getEstimatedSize() is called millions of times. Is it a good idea to create a new generator each time?
…or NdjsonOutputCodec. Signed-off-by: David Venable <dlv@amazon.com>
kkondaka
previously approved these changes
Apr 25, 2025
…ault createWriter implementation in OutputCodec. Signed-off-by: David Venable <dlv@amazon.com>
kkondaka
approved these changes
Apr 25, 2025
sb2k16
approved these changes
Apr 25, 2025
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
The
OutputCodecimplementations have members that are often bound to a specificOutputStream. This prevents them from being thread-safe and may also hide other issues if shared across multipleOutputStreams. In particular, this is presenting visible bugs when used with the new size estimation API.See this comment for some context: #5593 (comment)
The change provided is to create a single
OutputCodec.Writerfor eachOutputStream. This will ensure that the members used are bound to theOutputContext.This change adds partial support to get the work going. It specifically has these changes:
OutputCodec.JsonOutputCodec.JsonOutputCodec.Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.