Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17645

FormHttpMessageConverter should support non-String form values

    Details

      Description

      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
       

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              wsy wsy
              Last updater:
              Spring Issuemaster
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                47 weeks, 5 days ago