Announcement Announcement Module
Collapse
No announcement yet.
Dodgy Accept request header produces HttpMediaTypeNotAcceptableException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dodgy Accept request header produces HttpMediaTypeNotAcceptableException

    Hello.

    Some of our clients send requests with unparseable Accept headers. As a result, when methods are processed that are annotated with the @ResponseBody annotation, the AbstractMessageConverterMethodProcessor catches the IllegalArgumentException that is thrown and returns an empty list. In this case we would like to ignore the dodgy Accept header and return JSON by default (and we have wired a JSON message converter for that purpose).

    However, the writeWithMessageConverters() method never invokes the message converters because the acceptable media types list is empty and therefore the resulting compatible media types list, which is built by comparing acceptable and producible media types, is also empty and an HttpMediaTypeNotAcceptableException is thrown.

    Is there a way to solve this issue?

    TIA,
    B.
Working...
X