Affects: 6.1.2


While using the @RestClientTest I had an issue where I sent a Multipart request and wanted to confirm in a test that it was correctly formed.

But during testing I noticed that the request was handled by MultipartHelper and it didn't parse correctly my application/json part in UTF-8, resulting in some symbols being malformed. Although, it worked correctly while using the deprecated application/json; charset=utf-8. https://github.com/spring-projects/spring-framework/blob/f5b4f7d9e89ba21e2fd842f71d8a9af1dcfa0535/spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java#L361

After further investigation I noticed that DiskFileItemFactory is used with default values, with the charset set to this.defaultCharset = "ISO-8859-1".

Would it make sense for MultipartHelper to default to UTF-8?

FileUpload fileUpload = new FileUpload();
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setDefaultCharset(StandardCharsets.UTF_8.name());
fileUpload.setFileItemFactory(factory);

Comment From: sbrannen

Please refrain from opening both an issue and a PR for the same topic.

  • superseded by #31924