Avoid return value reference in potentially cached MethodParameter instance
Closes gh-28232
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -420,21 +420,21 @@ public class HandlerMethod {
|
|||||||
private class ReturnValueMethodParameter extends HandlerMethodParameter {
|
private class ReturnValueMethodParameter extends HandlerMethodParameter {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Object returnValue;
|
private final Class<?> returnValueType;
|
||||||
|
|
||||||
public ReturnValueMethodParameter(@Nullable Object returnValue) {
|
public ReturnValueMethodParameter(@Nullable Object returnValue) {
|
||||||
super(-1);
|
super(-1);
|
||||||
this.returnValue = returnValue;
|
this.returnValueType = (returnValue != null ? returnValue.getClass() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReturnValueMethodParameter(ReturnValueMethodParameter original) {
|
protected ReturnValueMethodParameter(ReturnValueMethodParameter original) {
|
||||||
super(original);
|
super(original);
|
||||||
this.returnValue = original.returnValue;
|
this.returnValueType = original.returnValueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getParameterType() {
|
public Class<?> getParameterType() {
|
||||||
return (this.returnValue != null ? this.returnValue.getClass() : super.getParameterType());
|
return (this.returnValueType != null ? this.returnValueType : super.getParameterType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -582,21 +582,21 @@ public class HandlerMethod {
|
|||||||
private class ReturnValueMethodParameter extends HandlerMethodParameter {
|
private class ReturnValueMethodParameter extends HandlerMethodParameter {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Object returnValue;
|
private final Class<?> returnValueType;
|
||||||
|
|
||||||
public ReturnValueMethodParameter(@Nullable Object returnValue) {
|
public ReturnValueMethodParameter(@Nullable Object returnValue) {
|
||||||
super(-1);
|
super(-1);
|
||||||
this.returnValue = returnValue;
|
this.returnValueType = (returnValue != null ? returnValue.getClass() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReturnValueMethodParameter(ReturnValueMethodParameter original) {
|
protected ReturnValueMethodParameter(ReturnValueMethodParameter original) {
|
||||||
super(original);
|
super(original);
|
||||||
this.returnValue = original.returnValue;
|
this.returnValueType = original.returnValueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getParameterType() {
|
public Class<?> getParameterType() {
|
||||||
return (this.returnValue != null ? this.returnValue.getClass() : super.getParameterType());
|
return (this.returnValueType != null ? this.returnValueType : super.getParameterType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user