-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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.