Skip to content

Commit ec4c28e

Browse files
jhoellerBenjamin Reed
authored and
Benjamin Reed
committed
Avoid return value reference in potentially cached MethodParameter instance
Closes spring-projectsgh-28232 (cherry picked from commit eefdd2c)
1 parent 955a9a8 commit ec4c28e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

org.springframework.web/src/main/java/org/springframework/web/method/HandlerMethod.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -253,16 +253,16 @@ public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
253253
*/
254254
private class ReturnValueMethodParameter extends HandlerMethodParameter {
255255

256-
private final Object returnValue;
256+
private final Class<?> returnValueType;
257257

258258
public ReturnValueMethodParameter(Object returnValue) {
259259
super(-1);
260-
this.returnValue = returnValue;
260+
this.returnValueType = (returnValue != null ? returnValue.getClass() : null);
261261
}
262262

263263
@Override
264264
public Class<?> getParameterType() {
265-
return (this.returnValue != null) ? this.returnValue.getClass() : super.getParameterType();
265+
return (this.returnValueType != null ? this.returnValueType : super.getParameterType());
266266
}
267267
}
268268

0 commit comments

Comments
 (0)