Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error status code set by handler interceptor overriden with status code 500 #20025

Closed
abadea-atl opened this issue Feb 3, 2020 · 3 comments
Closed

Comments

@abadea-atl
Copy link

Spring Boot 2.2.4

  1. Have a controller method with @Produces("application/x-protobuf").
  2. Have a handler interceptor that writes status code 401 to the response when the controller method from Fixed name of annotation and a typo in the code. #1 is invoked.

This returns an HTTP response with status code 500 and no body. After the fix of #19522, I expected status code 401 to be returned.

This seems to happen due to this code in AbstractMessageConverterMethodProcessor around line 316:

if (isContentTypePreset || !CollectionUtils.isEmpty(producibleMediaTypes)) {
    throw new HttpMessageNotWritableException(
            "No converter for [" + valueType + "] with preset Content-Type '" + contentType + "'");
}
throw new HttpMediaTypeNotAcceptableException(this.allSupportedMediaTypes);

producibleMediaTypes contains the controller's application/x-protobuf, so HttpMessageNotWritableException is thrown, which is turned into a 500 status code.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 3, 2020
@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Feb 4, 2020
@bclozel
Copy link
Member

bclozel commented Feb 4, 2020

Could you provide a sample application showing the issue?
I'm not sure I understand the problem here.

@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 11, 2020
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants