Skip to content

Handle encoding checks as in strTranscode#8687

Merged
headius merged 2 commits intojruby:jruby-9.4from
headius:same_encoding_nop
Mar 10, 2025
Merged

Handle encoding checks as in strTranscode#8687
headius merged 2 commits intojruby:jruby-9.4from
headius:same_encoding_nop

Conversation

@headius
Copy link
Member

@headius headius commented Mar 10, 2025

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.

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.
@headius headius added this to the JRuby 9.4.13.0 milestone Mar 10, 2025
@headius headius marked this pull request as ready for review March 10, 2025 21:28
@headius headius force-pushed the same_encoding_nop branch from cd30a8c to 76c7a4f Compare March 10, 2025 21:39
@headius headius merged commit cc696d3 into jruby:jruby-9.4 Mar 10, 2025
96 checks passed
@headius headius deleted the same_encoding_nop branch March 10, 2025 22:01
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.

1 participant