Skip to content

No originalFilename in MockMultipartFile now leads to add it just as part #26261

Closed
devhh/spring-framework
#2
@markusheiden

Description

@markusheiden

When using MockMultipartFile with an empty originalFilename (""), it now gets added to multi part requests just as a part, not as a file. When migrating from Spring Boot 2.3 to 2.4.1, this made my MockMvc test fail for a controller using a @RequestPart MultipartFile parameter causing a longer debugging session :-) It would be nice, if there had been a check (exception), that empty originalFilenames are no longer supported for MockMultipartFiles.

If the nullability of the originalFilename in MultipartFile is intended, org.springframework.web.multipart.support.StandardMultipartHttpServletRequest#parseRequest seems to be broken as it recognizes parts without filename not as files, so that they don't match MultipartFile parameters.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions