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

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

Closed
quaff opened this issue Jul 12, 2021 · 0 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@quaff
Copy link
Contributor

quaff commented Jul 12, 2021

@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);

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 12, 2021
@rstoyanchev rstoyanchev self-assigned this Jul 12, 2021
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 12, 2021
@rstoyanchev rstoyanchev added this to the 5.3.9 milestone Jul 12, 2021
quaff added a commit to quaff/spring-framework that referenced this issue Jul 23, 2021
quaff added a commit to quaff/spring-framework that referenced this issue Jul 26, 2021
Zoran0104 pushed a commit to Zoran0104/spring-framework that referenced this issue Aug 20, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants