Skip to content

FormHttpMessageConverter should support non-String form values [SPR-17645] #22174

@spring-projects-issues

Description

@spring-projects-issues

wsy opened SPR-17645 and commented

HttpEntity takes generic type T as request body.

When T is MultiValueMap<String, Object>, and the values of the map contains non-string values such as Integer, an invoke to RestTemplate (with Content-Type "application/x-www-form-urlencoded") will cause ClassCastException.

I've attached a demo project that can re-produce this bug. 

MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>();
body.add("Parameter1", "Value1"); // This is fine
body.add("Parameter2", 2147483647); // This value will trigger the bug after calling RestTemplate to send out this request.

I've already submitted a pull request. Pull Request #2078
 


Affects: 5.1.2

Attachments:

Referenced from: pull request #2078, and commits a82f049

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions