Skip to content

Reason of @ResponseStatus on handler method is not resolved by MessageSource #27156

Closed
@quaff

Description

@quaff
@ControllerAdvice
public class GlobalExceptionHandler {

	@ExceptionHandler(OptimisticLockingFailureException.class)
	@ResponseStatus(code = CONFLICT, reason = "optimistic.locking.failure")
	public void handleConflict() {
	}

}

If I move @ResponseStatus to Exception, It works fine.

if (StringUtils.hasText(reason)) {
response.sendError(status.value(), reason);
}

should keep consistency with
String resolvedReason = (this.messageSource != null ?
this.messageSource.getMessage(reason, null, reason, LocaleContextHolder.getLocale()) :
reason);

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions