Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockMvc duplicates PUT Parameter value [SPR-15753] #20308

spring-projects-issues opened this issue Jul 10, 2017 · 1 comment

MockMvc duplicates PUT Parameter value [SPR-15753] #20308

spring-projects-issues opened this issue Jul 10, 2017 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jul 10, 2017

Liqueur Librazy opened SPR-15753 and commented

When I run test against a Controller with @PutMapping and a parameter with custom type, say

public class Data {
    private String d1;
    private String d2;

public String test(Data d)



I'll get unexpected result that I got d1="a,a", d2="s,s".
But a normal PUT request works fine.

With some digging, I noticed that the first line of HttpPutFormContentFilter#getParameterValues(String)
returns null when requested normally but return the values in form data under test environment(when the request is of type MockHttpServletRequest).

I wrote a little spring boot project to demonstrate it. And there is some screenshot shows the difference between a real request and a mocked request.

Affects: 5.0 RC2


Issue Links:

  • #20390 Access to request parameters via @RequestParam within form PUT request handlers is broken (HttpPutFormContentFilter)
  • #20383 Parameter values are null when making a PUT request

Referenced from: commits eb84547, 8d74318

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 10, 2017

Rossen Stoyanchev commented

Yes this is an issue. The Servlet API does not expose form data as request parameters for PUT and PATCH while MockMvc always turns form data into request parameters.

Rather than potentially breaking existing tests, I think we can tighten checks in HttpPutFormContentFilter to ensure that indeed both query string and form data are present when merging the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants