-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Fix string array decode #35533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Fix string array decode #35533
+73
−0
Conversation
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
...on-empty lists Signed-off-by: prabal864 <940pps@gmail.com>
...on-empty lists Signed-off-by: prabal864 <940pps@gmail.com>
@Prabal864
Prabal864
force-pushed
the
fix-string-array-decode
branch
from
September 23, 2025 19:53
619b975
to
6f65c29
Compare
@spring-projects-issues
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
Sep 23, 2025
This is expected behavior documented at https://docs.spring.io/spring-framework/reference/web/webflux/reactive-spring.html#webflux-codecs-jackson (note at the end of section).
@rstoyanchev
rstoyanchev
removed
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
Oct 1, 2025
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.
Context / Problem
In Spring Framework 6 / WebFlux, using
WebClient
to decode a JSON array of strings(e.g., ["hello", "world"]) into a
List<String>
sometimes resulted in unexpected behavior:the JSON array was decoded as a single String containing the raw JSON ("["hello","world"]")
instead of a proper
List<String>
.This issue also occurs for empty arrays: decoding "[]" into a
List<String>
could producea list containing a single string "[]" rather than an empty list.
This behavior is confusing and can lead to subtle bugs when consuming JSON arrays
from reactive endpoints.
Solution
This PR adds self-contained reproducer tests to the
spring-webflux
moduledemonstrating the correct way to decode JSON arrays into
List<String>
usingParameterizedTypeReference
.Key points:
Embedded Netty server for tests
Correct JSON decoding
bodyToMono(new ParameterizedTypeReference<List<String>>() {})
correctly convertsthe JSON array into a
List<String>
.Covers both empty and non-empty arrays
decodeNotEmptyList()
→ decodes["hello", "world"]
into a list of two strings.decodeEmptyList()
→ decodes[]
into an empty list.Assertions
assertThat()
to verify the decoded lists exactly match expected values.Benefits
WebClient
correctly decodes JSON arrays into collections.Test Instructions
Run the tests locally:
./gradlew :spring-webflux:test --tests "org.springframework.web.reactive.function.client.StringArrayDecodeTests"