Handle encoding checks as in strTranscode#8687
Merged
headius merged 2 commits intojruby:jruby-9.4from Mar 10, 2025
Merged
Conversation
Logic in strTranscode evolved over the years to allow same-encoding requests to be no-ops. Those changes were never applied to rbByteEncode, resulting in same-encoding requests triggering errors when the transcoding subsystem saw nothing would be done. This complicated efforts to solve jruby#8682 by passing an encoding to the IOOutputStream constructor (ruby/json#759 and ruby/json#760). This patch allows using IOOutputStream and the byte[] IO API it calls with an externally-encoded IO by passing in an expected encoding for incoming bytes. All bytes will be treated as being encoded properly, and if the source and destination encoding is the same, rbByteEncode will return null to indicate no-op. Note that this misses some functionality of strTranscode in that it does not scrub the string for same-encoding requests. Partially addresses ruby/json#760. Fixes jruby#8686.
cd30a8c to
76c7a4f
Compare
3 tasks
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.
Logic in strTranscode evolved over the years to allow same-encoding requests to be no-ops. Those changes were never applied to rbByteEncode, resulting in same-encoding requests triggering errors when the transcoding subsystem saw nothing would be done. This complicated efforts to solve #8682 by passing an encoding to the IOOutputStream constructor (ruby/json#759 and ruby/json#760).
This patch allows using IOOutputStream and the byte[] IO API it calls with an externally-encoded IO by passing in an expected encoding for incoming bytes. All bytes will be treated as being encoded properly, and if the source and destination encoding is the same, rbByteEncode will return null to indicate no-op.
Note that this misses some functionality of strTranscode in that it does not scrub the string for same-encoding requests.
Partially addresses ruby/json#760.
Fixes #8686.