Lazily check log level within validation conditions
See gh-24672
This commit is contained in:
parent
7c4f0318bb
commit
33642345a4
|
|
@ -253,24 +253,22 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
*/
|
*/
|
||||||
private void doValidateClass(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader, Set<Class<?>> ifcs) {
|
private void doValidateClass(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader, Set<Class<?>> ifcs) {
|
||||||
if (proxySuperClass != Object.class) {
|
if (proxySuperClass != Object.class) {
|
||||||
final boolean infoEnabled = logger.isInfoEnabled();
|
|
||||||
final boolean debugEnabled = logger.isDebugEnabled();
|
|
||||||
Method[] methods = proxySuperClass.getDeclaredMethods();
|
Method[] methods = proxySuperClass.getDeclaredMethods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
int mod = method.getModifiers();
|
int mod = method.getModifiers();
|
||||||
if (!Modifier.isStatic(mod) && !Modifier.isPrivate(mod)) {
|
if (!Modifier.isStatic(mod) && !Modifier.isPrivate(mod)) {
|
||||||
if (Modifier.isFinal(mod)) {
|
if (Modifier.isFinal(mod)) {
|
||||||
if (infoEnabled && implementsInterface(method, ifcs)) {
|
if (logger.isInfoEnabled() && implementsInterface(method, ifcs)) {
|
||||||
logger.info("Unable to proxy interface-implementing method [" + method + "] because " +
|
logger.info("Unable to proxy interface-implementing method [" + method + "] because " +
|
||||||
"it is marked as final: Consider using interface-based JDK proxies instead!");
|
"it is marked as final: Consider using interface-based JDK proxies instead!");
|
||||||
}
|
}
|
||||||
if (debugEnabled) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Final method [" + method + "] cannot get proxied via CGLIB: " +
|
logger.debug("Final method [" + method + "] cannot get proxied via CGLIB: " +
|
||||||
"Calls to this method will NOT be routed to the target instance and " +
|
"Calls to this method will NOT be routed to the target instance and " +
|
||||||
"might lead to NPEs against uninitialized fields in the proxy instance.");
|
"might lead to NPEs against uninitialized fields in the proxy instance.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (debugEnabled && !Modifier.isPublic(mod) && !Modifier.isProtected(mod) &&
|
else if (logger.isDebugEnabled() && !Modifier.isPublic(mod) && !Modifier.isProtected(mod) &&
|
||||||
proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
|
proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
|
||||||
logger.debug("Method [" + method + "] is package-visible across different ClassLoaders " +
|
logger.debug("Method [" + method + "] is package-visible across different ClassLoaders " +
|
||||||
"and cannot get proxied via CGLIB: Declare this method as public or protected " +
|
"and cannot get proxied via CGLIB: Declare this method as public or protected " +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue