Polish contribution

Closes gh-32412
This commit is contained in:
Sam Brannen
2024-03-11 17:01:15 +01:00
parent 3e48031601
commit 04e69bdb26
2 changed files with 87 additions and 45 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.beans.factory.support;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Objects;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -289,10 +288,10 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
@Nullable
private <T> T processReturnType(Method method, @Nullable T returnValue) {
Class<?> returnType = method.getReturnType();
if (returnType != void.class && returnType.isPrimitive()) {
return Objects.requireNonNull(returnValue, () -> "Null return value from replacer does not match primitive return type for: " + method);
if (returnValue == null && returnType != void.class && returnType.isPrimitive()) {
throw new IllegalStateException(
"Null return value from MethodReplacer does not match primitive return type for: " + method);
}
return returnValue;
}
}