Skip to content

Commit f7e7d1b

Browse files
committed
Merge branch '6.1.x'
2 parents df238d0 + 8a84241 commit f7e7d1b

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,9 @@
2020

2121
import org.springframework.aop.Advisor;
2222
import org.springframework.aop.TargetSource;
23+
import org.springframework.aop.framework.AopConfigException;
2324
import org.springframework.aop.support.AopUtils;
25+
import org.springframework.beans.factory.BeanCreationException;
2426
import org.springframework.beans.factory.BeanFactory;
2527
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
2628
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@@ -97,7 +99,13 @@ protected List<Advisor> findEligibleAdvisors(Class<?> beanClass, String beanName
9799
List<Advisor> eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
98100
extendAdvisors(eligibleAdvisors);
99101
if (!eligibleAdvisors.isEmpty()) {
100-
eligibleAdvisors = sortAdvisors(eligibleAdvisors);
102+
try {
103+
eligibleAdvisors = sortAdvisors(eligibleAdvisors);
104+
}
105+
catch (BeanCreationException ex) {
106+
throw new AopConfigException("Advisor sorting failed with unexpected bean creation, probably due " +
107+
"to custom use of the Ordered interface. Consider using the @Order annotation instead.", ex);
108+
}
101109
}
102110
return eligibleAdvisors;
103111
}

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessorTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,15 +36,17 @@
3636
* Tests for {@link AspectJAdvisorBeanRegistrationAotProcessor}.
3737
*
3838
* @author Sebastien Deleuze
39+
* @since 6.1
3940
*/
4041
class AspectJAdvisorBeanRegistrationAotProcessorTests {
4142

4243
private final GenerationContext generationContext = new TestGenerationContext();
4344

4445
private final RuntimeHints runtimeHints = this.generationContext.getRuntimeHints();
4546

47+
4648
@Test
47-
void shouldProcessesAspectJClass() {
49+
void shouldProcessAspectJClass() {
4850
process(AspectJClass.class);
4951
assertThat(reflection().onType(AspectJClass.class).withMemberCategory(MemberCategory.DECLARED_FIELDS))
5052
.accepts(this.runtimeHints);

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1052,16 +1052,16 @@ public static Object getValue(@Nullable Annotation annotation, @Nullable String
10521052
return null;
10531053
}
10541054
try {
1055-
Method method = annotation.annotationType().getDeclaredMethod(attributeName);
1056-
return invokeAnnotationMethod(method, annotation);
1057-
}
1058-
catch (NoSuchMethodException ex) {
1059-
return null;
1055+
for (Method method : annotation.annotationType().getDeclaredMethods()) {
1056+
if (method.getName().equals(attributeName) && method.getParameterCount() == 0) {
1057+
return invokeAnnotationMethod(method, annotation);
1058+
}
1059+
}
10601060
}
10611061
catch (Throwable ex) {
10621062
handleValueRetrievalFailure(annotation, ex);
1063-
return null;
10641063
}
1064+
return null;
10651065
}
10661066

10671067
/**

0 commit comments

Comments
 (0)