Skip to content

Content-Type not set correctly on @ControllerAdvice [SPR-17394] #21927

Closed
@spring-projects-issues

Description

@spring-projects-issues

mpapenbr opened SPR-17394 and commented

Given a class with @ControllerAdvice annotation

@ControllerAdvice
@RequestMapping(produces = {  "application/vnd.someapp-v1.0+json;charset=utf-8" })
public class RestErrorHandler {
...
@ExceptionHandler(OperationWithProblemsException.class) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) 
@ResponseBody public OperationResult processOperationWithProblemsException(OperationWithProblemsException ex) {  
  return ex.getResult();
}

When running with Spring 5.0.X the content type specified in the produces-attribute of the RequestMapping annotation was respected and sent to the client upon this exception.

Starting with Spring 5.1.0 this has somehow changed and now I get 

application/json;charset=UTF-8

instead of the expected

application/vnd.someapp-v1.0+json;charset=utf-8

Affects: 5.1.1

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions