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

MockHttpServletRequest shouldn't allow calls to both getReader and getInputStream [SPR-16499] #21042

spring-projects-issues opened this issue Feb 14, 2018 · 1 comment
in: test type: enhancement


Copy link

@spring-projects-issues spring-projects-issues commented Feb 14, 2018

Av Pinzur opened SPR-16499 and commented

Per the ServletRequest documentation, ServletRequest's two methods for reading the request body - getReader and getInputStream - cannot be used in combination. Implementations are supposed to throw IllegalStateException from either method if the other has already been called.

Revising MockHttpServletRequest to conform to this documented behavior will reinforce the value of Spring Test by allowing users to catch subtle bugs during unit/integration testing, rather than discovering non-compliant usage patterns only when running in an actual container.

Affects: 4.3.14, 5.0.3

Issue Links:

  • #21048 MockHttpServletRequest.getReader, getInputStream should each return the same object on repeat calls

Referenced from: pull request #1688, and commits 3fc8ec4

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 14, 2018

Av Pinzur commented

I'll be submitting a pull request shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: test type: enhancement
None yet

No branches or pull requests

2 participants