Spring Boot 2.1.0: Cannot call getReader() after getInputStream()

Issue #190 resolved
Illia Sorokoumov created an issue

I'm facing a similar issue to the guy here: https://stackoverflow.com/questions/53818075/mockmvc-error-when-validating-resultmatcher-for-swagger-2-on-spring-boot-2-1-0

While trying to migrate Spring Boot from 2.0.6 to 2.1.2 a lot of tests fail with

java.lang.IllegalStateException: Cannot call getReader() after getInputStream() has already been called for the current request
    at org.springframework.mock.web.MockHttpServletRequest.getReader(MockHttpServletRequest.java:716)
    at com.atlassian.oai.validator.mockmvc.MockMvcRequest.getReader(MockMvcRequest.java:119)
    at com.atlassian.oai.validator.mockmvc.MockMvcRequest.getBody(MockMvcRequest.java:100)
    at com.atlassian.oai.validator.mockmvc.MockMvcRequest.of(MockMvcRequest.java:91)
    at com.atlassian.oai.validator.mockmvc.OpenApiMatchers.lambda$isValid$0(OpenApiMatchers.java:56)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:195)

BTW Some tests still pass, so it seems to depend on whether something within Spring has called getInputStream() or not.

Comments (4)

  1. Illia Sorokoumov Account Deactivated reporter

    Well, it seems to have the same root cause as #181, however this one is essentially preventing anybody who is using the library to migrate to newer version of Spring Boot, which the other one is about supporting RestAssuredMockMvc

  2. Log in to comment