Deprecate ClassUtils.isCglibProxy methods in favor of AOP-level checks

Closes gh-22706
This commit is contained in:
Juergen Hoeller 2019-03-29 11:12:49 +01:00
parent f273fa990c
commit 57de2e0900
3 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -166,7 +166,7 @@ class CglibAopProxy implements AopProxy, Serializable {
Assert.state(rootClass != null, "Target class must be available for creating a CGLIB proxy");
Class<?> proxySuperClass = rootClass;
if (ClassUtils.isCglibProxyClass(rootClass)) {
if (rootClass.getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)) {
proxySuperClass = rootClass.getSuperclass();
Class<?>[] additionalInterfaces = rootClass.getInterfaces();
for (Class<?> additionalInterface : additionalInterfaces) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -66,8 +66,8 @@ public abstract class AopUtils {
* @see #isCglibProxy
*/
public static boolean isAopProxy(@Nullable Object object) {
return (object instanceof SpringProxy &&
(Proxy.isProxyClass(object.getClass()) || ClassUtils.isCglibProxyClass(object.getClass())));
return (object instanceof SpringProxy && (Proxy.isProxyClass(object.getClass()) ||
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)));
}
/**
@ -91,7 +91,8 @@ public abstract class AopUtils {
* @see ClassUtils#isCglibProxy(Object)
*/
public static boolean isCglibProxy(@Nullable Object object) {
return (object instanceof SpringProxy && ClassUtils.isCglibProxy(object));
return (object instanceof SpringProxy &&
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR));
}
/**

View File

@ -841,7 +841,9 @@ public abstract class ClassUtils {
* @param object the object to check
* @see #isCglibProxyClass(Class)
* @see org.springframework.aop.support.AopUtils#isCglibProxy(Object)
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
*/
@Deprecated
public static boolean isCglibProxy(Object object) {
return isCglibProxyClass(object.getClass());
}
@ -850,7 +852,9 @@ public abstract class ClassUtils {
* Check whether the specified class is a CGLIB-generated class.
* @param clazz the class to check
* @see #isCglibProxyClassName(String)
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
*/
@Deprecated
public static boolean isCglibProxyClass(@Nullable Class<?> clazz) {
return (clazz != null && isCglibProxyClassName(clazz.getName()));
}
@ -858,7 +862,9 @@ public abstract class ClassUtils {
/**
* Check whether the specified class name is a CGLIB-generated class.
* @param className the class name to check
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
*/
@Deprecated
public static boolean isCglibProxyClassName(@Nullable String className) {
return (className != null && className.contains(CGLIB_CLASS_SEPARATOR));
}