Skip to content

AbstractMessageConverterMethodProcessor returns allSupportedMediaTypes with HttpMediaTypeNotAcceptableException [SPR-10175] #14808

Closed
@spring-projects-issues

Description

@spring-projects-issues

Michael Osipov opened SPR-10175 and commented

When a Controller is able respond with a limited set of media types and the client requests a not supported media type the server respponds with a HttpMediaTypeNotAcceptableException with all supported media types.

An example request mapping:

@RequestMapping(value = "/{project:[A-Z0-9_+\\.\\(\\)=\\- ]+}", method = RequestMethod.GET)
  public ResponseEntity<Object> lookupProject(@PathVariable String project,
    @RequestParam(value = "attributes", required = false) String[] attributes,
    @RequestParam(value = "outputType", required = false, defaultValue = "hash") OutputType outputType)

Controller mapping

@Controller
@RequestMapping("/rest/db-search")
public class DbSearchController

Now, let's say a client issues this GET request:

GET /context/rest/db-search/1314136 HTTP/1.1
Host: <host>:8080
User-Agent: ...
Accept: text/csv
Accept-Encoding: gzip, deflate

The aforementioned exception is thrown. It should contain the producible media types instead of all supported ones.

See attached screenshots for runtime inspection.


Affects: 3.1.3, 3.2 GA

Attachments:

Backported to: 3.1.4

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions