|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 |
|
21 | 21 | import org.springframework.aop.Advisor;
|
22 | 22 | import org.springframework.aop.TargetSource;
|
| 23 | +import org.springframework.aop.framework.AopConfigException; |
23 | 24 | import org.springframework.aop.support.AopUtils;
|
| 25 | +import org.springframework.beans.factory.BeanCreationException; |
24 | 26 | import org.springframework.beans.factory.BeanFactory;
|
25 | 27 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
26 | 28 | import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
@@ -97,7 +99,13 @@ protected List<Advisor> findEligibleAdvisors(Class<?> beanClass, String beanName
|
97 | 99 | List<Advisor> eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
|
98 | 100 | extendAdvisors(eligibleAdvisors);
|
99 | 101 | 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 | + } |
101 | 109 | }
|
102 | 110 | return eligibleAdvisors;
|
103 | 111 | }
|
|
0 commit comments