From 55e17ef30636b58052b8a53322394ec9d91df22e Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 28 Jul 2021 14:44:48 +0100 Subject: [PATCH] Polishing contribution Closes gh-27203 --- .../web/method/HandlerMethod.java | 6 +++--- .../support/InvocableHandlerMethod.java | 7 ++++--- .../ServletInvocableHandlerMethod.java | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java b/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java index 90e93fd3642..35bf35ac01c 100644 --- a/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java +++ b/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java @@ -105,12 +105,12 @@ public class HandlerMethod { this(bean, method, null); } - /** * Variant of {@link #HandlerMethod(Object, Method)} that - * also accepts a {@link MessageSource}. + * also accepts a {@link MessageSource} for use from sub-classes. + * @since 5.3.10 */ - public HandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource) { + protected HandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource) { Assert.notNull(bean, "Bean is required"); Assert.notNull(method, "Method is required"); this.bean = bean; diff --git a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java index 68d7b94d54d..80f98393f3a 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,9 +74,10 @@ public class InvocableHandlerMethod extends HandlerMethod { /** * Variant of {@link #InvocableHandlerMethod(Object, Method)} that - * also accepts a {@link MessageSource}. + * also accepts a {@link MessageSource}, for use in sub-classes. + * @since 5.3.10 */ - public InvocableHandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource) { + protected InvocableHandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource) { super(bean, method, messageSource); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java index 88343c3dbfc..8b2ba44f3ec 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,13 +69,6 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod { @Nullable private HandlerMethodReturnValueHandlerComposite returnValueHandlers; - /** - * Variant of {@link #ServletInvocableHandlerMethod(Object, Method)} that - * also accepts a {@link MessageSource}. - */ - public ServletInvocableHandlerMethod(Object handler, Method method, @Nullable MessageSource messageSource) { - super(handler, method, messageSource); - } /** * Creates an instance from the given handler and method. @@ -84,6 +77,16 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod { super(handler, method); } + /** + * Variant of {@link #ServletInvocableHandlerMethod(Object, Method)} that + * also accepts a {@link MessageSource}, e.g. to resolve + * {@code @ResponseStatus} messages with. + * @since 5.3.10 + */ + public ServletInvocableHandlerMethod(Object handler, Method method, @Nullable MessageSource messageSource) { + super(handler, method, messageSource); + } + /** * Create an instance from a {@code HandlerMethod}. */