diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java index 3c0b63bc320b..d2da45684e66 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2022 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. @@ -281,16 +281,16 @@ public T getMethodAnnotation(Class annotationType) { */ private class ReturnValueMethodParameter extends HandlerMethodParameter { - private final Object returnValue; + private final Class returnValueType; public ReturnValueMethodParameter(Object returnValue) { super(-1); - this.returnValue = returnValue; + this.returnValueType = (returnValue != null ? returnValue.getClass() : null); } @Override public Class getParameterType() { - return (this.returnValue != null ? this.returnValue.getClass() : super.getParameterType()); + return (this.returnValueType != null ? this.returnValueType : super.getParameterType()); } } 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 cdbf7315a502..edccd1b4dae6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2022 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. @@ -276,16 +276,16 @@ public T getMethodAnnotation(Class annotationType) { */ private class ReturnValueMethodParameter extends HandlerMethodParameter { - private final Object returnValue; + private final Class returnValueType; public ReturnValueMethodParameter(Object returnValue) { super(-1); - this.returnValue = returnValue; + this.returnValueType = (returnValue != null ? returnValue.getClass() : null); } @Override public Class getParameterType() { - return (this.returnValue != null ? this.returnValue.getClass() : super.getParameterType()); + return (this.returnValueType != null ? this.returnValueType : super.getParameterType()); } }