Browse Source

AspectJExpressionPointcut leniently ignores non-composable interfaces

Issue: SPR-17003
pull/1889/merge
Juergen Hoeller 8 years ago
parent
commit
bccff73e2b
  1. 6
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  2. 2
      spring-core/src/main/java/org/springframework/util/ClassUtils.java

6
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

@ -433,10 +433,16 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
// Note: AspectJ is only going to take Method.getDeclaringClass() into account. // Note: AspectJ is only going to take Method.getDeclaringClass() into account.
Set<Class<?>> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass); Set<Class<?>> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass);
if (ifcs.size() > 1) { if (ifcs.size() > 1) {
try {
Class<?> compositeInterface = ClassUtils.createCompositeInterface( Class<?> compositeInterface = ClassUtils.createCompositeInterface(
ClassUtils.toClassArray(ifcs), targetClass.getClassLoader()); ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface); targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
} }
catch (IllegalArgumentException ex) {
// Implemented interfaces probably expose conflicting method signatures...
// Proceed with original target method.
}
}
} }
return getShadowMatch(targetMethod, method); return getShadowMatch(targetMethod, method);
} }

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

@ -771,6 +771,8 @@ public abstract class ClassUtils {
* @param interfaces the interfaces to merge * @param interfaces the interfaces to merge
* @param classLoader the ClassLoader to create the composite Class in * @param classLoader the ClassLoader to create the composite Class in
* @return the merged interface as Class * @return the merged interface as Class
* @throws IllegalArgumentException if the specified interfaces expose
* conflicting method signatures (or a similar constraint is violated)
* @see java.lang.reflect.Proxy#getProxyClass * @see java.lang.reflect.Proxy#getProxyClass
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

Loading…
Cancel
Save