Browse Source

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

Closes gh-22706
pull/22715/head
Juergen Hoeller 7 years ago
parent
commit
57de2e0900
  1. 4
      spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
  2. 9
      spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
  3. 6
      spring-core/src/main/java/org/springframework/util/ClassUtils.java

4
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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) {

9
spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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));
}
/**

6
spring-core/src/main/java/org/springframework/util/ClassUtils.java

@ -841,7 +841,9 @@ public abstract class ClassUtils { @@ -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 { @@ -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 { @@ -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));
}

Loading…
Cancel
Save