Repository navigation
fix: JSONB ASM direct-write under-counted object frame bytes (#7616) - #7617
Merged
Merged
Conversation
wenshao
commented
Apr 12, 2026
wenshao
left a comment
Member
Author
There was a problem hiding this comment.
[Suggestion] The fastjson1-compatible JSON.writeJSONString(...) methods in this PR now preserve UseISO8601DateFormat over an externally supplied dateFormat, but fastjson1-compatible/src/main/java/com/alibaba/fastjson/support/jaxrs/FastJsonProvider.java still calls context.setDateFormat(dateFormat) unconditionally in writeJSONStringWithFastJsonConfig(...). This leaves the JAX-RS integration with the old precedence and makes behavior inconsistent across integrations. Consider applying the same !context.isDateFormatISO8601() guard there as well.
— gpt-5.4 via Qwen Code /review
…city (#7616) The minCapacity formula in genMethodWriteJSONB was inverted: when a field group writes BC_OBJECT (start) or BC_OBJECT_END (end), each takes 1 byte, but the formula contributed 0 in those cases. For Beans whose direct-write capacity was tight (e.g. a single large UTF-16 String field), the buffer ended up 2 bytes short, causing JSONB.IO.writeStringUTF16's arraycopy to overrun. Regression introduced in 2.0.56. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Multi-field UTF-16: ensures the per-field stringCapacity stays in sync with the BC_OBJECT/BC_OBJECT_END framing accounting. - Split-group bean: exercises the (group.start=false, group.end=false) middle-direct-group code path that the inverted formula previously over-allocated by 2 bytes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wenshao
force-pushed
the
fix/issue-7616-asm-jsonb-capacity
branch
from
April 12, 2026 06:55
8c542ec to
75a784f
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.
Summary
JSONB.toBytesthrowsArrayIndexOutOfBoundsExceptioninJSONB$IO.writeStringUTF16when serializing a Bean field that holds a large UTF-16 String. Regression introduced in 2.0.56.ObjectWriterCreatorASM.genMethodWriteJSONB, the buffer pre-sizing formula was inverted —(group.start ? 0 : 1) + (group.end ? 0 : 1)contributed 0 bytes exactly whenBC_OBJECT/BC_OBJECT_ENDwere actually written, leaving the buffer 2 bytes short for tight Beans (e.g. one large UTF-16 String field).(group.start ? 1 : 0) + (group.end ? 1 : 0).Test plan
Issue7616reproducing the original report (nested Bean →List<Message>→ 232,768-char UTF-16 payload), verifies round-trip.JSONBTest*,JSONWriterJSONBTest,ObjectWriterCreatorASMTest, 159 tests).🤖 Generated with Claude Code