Apply charset preprocessing to Mono JSON decoding - #37217
Closed
blackdurumi wants to merge 1 commit into
Closed
Conversation
The Jackson 2 decoder already preprocesses non-UTF-8 input for streaming decoding, but decodeToMono bypassed the processInput hook and passed raw buffers to Jackson. Applying the same preprocessing before aggregation keeps Mono and streaming decoding behavior consistent. Constraint: Preserve the existing protected processInput extension point and the configured DataBuffer aggregation limit. Rejected: Decode the joined buffer directly | That leaves non-UTF-8 Mono payloads without the charset normalization already used by the streaming path. Confidence: high Scope-risk: narrow Directive: Keep processInput applied before aggregation whenever Mono decoding shares the Jackson 2 input path. Tested: Jackson2JsonDecoderTests; spring-web:check; full ./gradlew build; targeted Jetty integration test rerun. Not-tested: No known verification gaps. Signed-off-by: jungh8n <jh981113@naver.com>
Contributor
Author
|
I submitted this PR before confirming whether a contribution would be welcome. Based on the maintainer guidance, I’m closing it for now and will wait for the issue to be triaged. I’d be happy to revisit it if a PR is requested. |
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.
Fixes #37195
Problem
Jackson2JsonDecoderalready preprocesses non-UTF-8 input for streaming decoding because Jackson's asynchronous parser only accepts UTF-8 (or ASCII). However,decodeToMonojoined the originalDataBufferinput and passed it directly to Jackson, bypassing that preprocessing.As a result, a BOM-free ISO-8859-1 JSON payload could be decoded successfully through the streaming path but fail through the
Monopath.Solution
processInputhook beforeDataBufferUtils.joinindecodeToMono.decode(DataBuffer, ...)behavior unchanged.This makes the
Monoand streaming paths use the same charset handling.Tests
The regression test uses BOM-free ISO-8859-1 JSON split across two data buffers and verifies that
decodeToMonoreturns the expected values.Verified with:
JAVA_HOME=/opt/homebrew/opt/openjdk@25 ./gradlew :spring-web:test --tests org.springframework.http.codec.json.Jackson2JsonDecoderTestsJAVA_HOME=/opt/homebrew/opt/openjdk@25 ./gradlew :spring-web:checkJAVA_HOME=/opt/homebrew/opt/openjdk@25 ./gradlew buildJAVA_HOME=/opt/homebrew/opt/openjdk@25 ./gradlew :spring-webflux:test --tests org.springframework.web.reactive.result.method.annotation.RequestMappingMessageConversionIntegrationTests.personResponseBodyWithObservable