Conversation
ProxyingHandlerMethodArgumentResolver only bound the request parameter map, so the files of a multipart request never reached the map backing the projection proxy and a MultipartFile property of a @ProjectedPayload interface always resolved to null. The resolver now also binds the files of a MultipartRequest the same way WebDataBinder does: a single file as is, multiple files for the same name as a List. Closes spring-projects#1136 Signed-off-by: Seonggon Cho <jmsmg1@me.com>
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.
Interface-based form-backing objects created by
ProxyingHandlerMethodArgumentResolverreturnnullforMultipartFileproperties, see #1136.Cause.
createAttributebindsrequest.getParameterMap()only. The files of a multipart request live inMultipartRequest#getMultiFileMap(), so they never reach theMapbacking the projection proxy, andbindRequestParametersis a no-op, so there is no second binding pass either. In a@NullMarkedcontext the proxy's nullness validation turns thenullinto aNullPointerException("Return value is null but must not be null").Change.
createAttributenow also adds the files of aMultipartRequestto the property values, followingWebDataBinder#bindMultipart: a single file is bound as is, multiple files for the same name as aList<MultipartFile>. Requests without aMultipartRequestare unaffected.Tests. Two unit tests in
ProxyingHandlerMethodArgumentResolverUnitTests(bindsMultipartFileIntoProjectedPayload,bindsMultipleMultipartFilesIntoProjectedPayload) resolve a@ProjectedPayloadinterface from aMockMultipartHttpServletRequest. Both fail without the change and pass with it;EnableSpringDataWebSupportIntegrationTestsstill passes.Open question. I kept the change local to the resolver. Alternatively
MapDataBindercould extendWebRequestDataBinderand usebind(WebRequest), which would additionally bind ServletParts when noMultipartResolveris configured. Happy to switch if you prefer that route.Closes #1136