Skip to content

Proposal: Preserve Original 'Produces' Media Types in Exception Handlers #35621

@IMurzich

Description

@IMurzich

I have a REST service that can produce responses in either JSON or XML, as defined by the produces = {"application/xml", "application/json"} parameter.

The goal is to ensure that when an exception occurs, the error response is returned using the same media type that the client requested (e.g., XML for an XML request, JSON for a JSON request).

However, the current behavior during exception handling is to overwrite the original produces list. If a custom exception handler does not explicitly declare its own produces parameter, this results in an empty list of supported media types, which can lead to unexpected behavior.

My proposal is to modify this logic so that the original produces list from the endpoint is preserved and used as a fallback whenever the exception handler itself does not specify one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions