Skip to content

Commit bccff73

Browse files
committed
AspectJExpressionPointcut leniently ignores non-composable interfaces
Issue: SPR-17003
1 parent f58854f commit bccff73

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,15 @@ private ShadowMatch getTargetShadowMatch(Method method, Class<?> targetClass) {
433433
// Note: AspectJ is only going to take Method.getDeclaringClass() into account.
434434
Set<Class<?>> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass);
435435
if (ifcs.size() > 1) {
436-
Class<?> compositeInterface = ClassUtils.createCompositeInterface(
437-
ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
438-
targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
436+
try {
437+
Class<?> compositeInterface = ClassUtils.createCompositeInterface(
438+
ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
439+
targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
440+
}
441+
catch (IllegalArgumentException ex) {
442+
// Implemented interfaces probably expose conflicting method signatures...
443+
// Proceed with original target method.
444+
}
439445
}
440446
}
441447
return getShadowMatch(targetMethod, method);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, @Nulla
771771
* @param interfaces the interfaces to merge
772772
* @param classLoader the ClassLoader to create the composite Class in
773773
* @return the merged interface as Class
774+
* @throws IllegalArgumentException if the specified interfaces expose
775+
* conflicting method signatures (or a similar constraint is violated)
774776
* @see java.lang.reflect.Proxy#getProxyClass
775777
*/
776778
@SuppressWarnings("deprecation")

0 commit comments

Comments
 (0)