Skip to content

JSON (jackson) @RequestBody marshalling throws awkward exception [SPR-7439] #12097

Closed

Description

@spring-projects-issues

Daniel Robert opened SPR-7439 and commented

When utilizing a @Controller method with annotation @RequestBody and 'application/json' content type with Jackson on the classpath, MappingJacksonHttpMessageConverter throws a 'JsonParseException' (subclass of IOException) when given invalid JSON.

According to AbstractHttpMessageConverter.readInternal()'s documentation, the HttpMessageNotReadableException exception is more appropriate for conversion errors.

The side effect of this is that DefaultHandlerExceptionResolver throws a 500 Internal Server Error instead of the expected 400 Bad Request.


Affects: 3.0.2

Issue Links:

Referenced from: commits ac1d2d9, fa3e9bd

1 votes, 5 watchers

Activity

  1. spring-projects-issues commented on Aug 11, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Arjen Poutsma commented

    Done, thanks for spotting this!

  2. spring-projects-issues commented on Feb 1, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Matt Zimmer commented

    In the case that the message body is missing a java.io.EOFException is thrown. An org.springframework.http.converter.HttpMessageNotReadableException is more appropriate in this case as well.

  3. spring-projects-issues commented on Jun 6, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Arjen Poutsma commented

    Fixed for 3.1

  4. added
    type: enhancement
    in: web
    on Jan 11, 2019
  5. added this to the 3.1 M2 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions