NPE on no request body

Issue #71 resolved
Arash Bizhan created an issue

When using spring mockmvc, if I submit a GET with no content set - which is valid - I get an NPE in the swagger validation as it tries to read the body.

Comments (10)

  1. Sven Döring

    Hi Arash.

    Do you have a stack trace? Or at least the line this is happening? Which version of the Swagger Request Validator are you using?

    Kind regards

  2. Arash Bizhan reporter

    Sure, it is pretty obvious actually. Version 1.2.1 MockMvcRequest Line 98. If request has no body, reader is null and reader.readLine() is NPE.

  3. Sven Döring

    Ahh, thanks, I see. Perhaps if we tickle @daknin he can take a look at that without obligation. 👼

  4. Darrell King

    A bit of digging turned up SPR-15215 which was released in Spring 4.3.7. This changed MockHttpServletRequest.getReader() to return an empty Reader instead of null. This PR will fix the issue

  5. Genz, Carlos (CORP)

    @daknin, when is this going to be released? I have been expecting a 1.2.2 release to come out with this fix in.. thanks

  6. James Navin

    Apologies - that was my bad. I merged the PR but failed to notice the release didn't go out. Trying to sort it out now.

  7. Log in to comment