Skip to content

Avoid matching multipart parameters annotated with @ModelAttribute #3277

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Apr 24, 2025

The ProxyHandlerMethodArgumentResolver now avoids matching multipart parameters annotated with @ModelAttribute. This allows multipart parameters to be handled by RequestParamMethodArgumentResolver which properly handles multipart arguments.

In 3.3.3 the ProxyingHandlerMethodArgumentResolver would report that it does not support the @ModelAttribute MultipartFile file parameter and then the next handler in the chain (RequestParamMethodArgumentResolver) was able to properly handle the multipart file arg.

In 3.3.4 (commit) the ProxyingHandlerMethodArgumentResolver reports that it does support the @ModelAttribute MultipartFile file parameter and then it fails to properly handle the multipart file arg.

Fixes #3258
Related tickets #2937

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

The ProxyHandlerMethodArgumentResolver now avoids matching multipart parameters annotated with @ModelAttribute. This allows multipart parameters to be handled by RequestParamMethodArgumentResolver which properly handles multipart arguments.

Fixes spring-projects#3258
Related tickets spring-projects#2937

Signed-off-by: Chris Bono <[email protected]>
@onobc onobc added the type: bug A general bug label Apr 24, 2025
@onobc onobc requested review from odrotbohm and mp911de April 24, 2025 15:53
if (parameter.getParameterAnnotation(ProjectedPayload.class) != null
|| parameter.getParameterAnnotation(ModelAttribute.class) != null) {
// Annotated parameter (excluding multipart @ModelAttribute)
if (parameter.hasParameterAnnotation(ProjectedPayload.class) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the proxy handler does not properly handle multipart arguments, but the request param method handler does properly support multipart params. Is this the proper fix or should the proxy handler also support multipart args properly? cc: @odrotbohm @mp911de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring Data Commons 3.3.4 breaks @ModelAttribute handling
1 participant