Skip to content

Conversation

kwondh5217
Copy link
Contributor

Motivation:

This PR is a follow-up to #6072, which added support for mapping all query parameters into a Map<String, String>. However, it does not handle cases where multiple values exist for the same query parameter key.

For example:

GET /foo?a=1&a=2&b=3

The current implementation only retains the last value a=2, losing a=1.
To better support multi-value query parameters, we introduce support for Map<String, List<?>>.

Modifications:

  • Enhanced ofQueryParamMap in AnnotatedValueResolver to support:
    • Map<String, String> → Single-value mapping (existing behavior).
    • Map<String, List> → Multi-value mapping (new behavior).
  • If the value type of the map is List<?>, query parameters with the same key are collected into a list.
  • Added validation to ensure that the value type is List<?>. If an unsupported type is used, an IllegalArgumentException is thrown.

Result:

  • Users can now use @param Map<String, List<?>> to collect multi-value query parameters.

@ikhoon ikhoon added this to the 1.33.0 milestone Feb 24, 2025
@kwondh5217 kwondh5217 requested a review from ikhoon February 24, 2025 12:19
@kwondh5217 kwondh5217 changed the title Support multi-value query parameters with @Param Map<String, List<?>> Support multi-value query parameters Feb 24, 2025
Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left small suggestions. Thanks!

@kwondh5217
Copy link
Contributor Author

Thanks for the suggestions, @minwoox!
I’ve pushed the updates now.

@kwondh5217 kwondh5217 force-pushed the main branch 3 times, most recently from 236cb7f to d7daa0d Compare April 9, 2025 11:43
@kwondh5217
Copy link
Contributor Author

Thanks for the suggestions, @jrhee17 !
I’ve pushed the updates now.

@kwondh5217 kwondh5217 force-pushed the main branch 3 times, most recently from 95ad3d0 to 0dff99c Compare April 16, 2025 16:24
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.64%. Comparing base (8150425) to head (690480e).
Report is 62 commits behind head on main.

Files with missing lines Patch % Lines
...rnal/server/annotation/AnnotatedValueResolver.java 86.20% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6118      +/-   ##
============================================
+ Coverage     74.46%   74.64%   +0.17%     
- Complexity    22234    22480     +246     
============================================
  Files          1963     1972       +9     
  Lines         82437    83018     +581     
  Branches      10764    10805      +41     
============================================
+ Hits          61385    61967     +582     
+ Misses        15918    15901      -17     
- Partials       5134     5150      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @kwondh5217!

Signed-off-by: Daeho Kwon <trewq231@naver.com>
@jrhee17 jrhee17 merged commit d4f8a23 into line:main May 12, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants