You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AnnotationAwareOrderComparator getPriority does not work if bean is a proxy [SPR-13884] #18457
Identified a bug in the AnnotationAwareOrderComparator during investigating a NonUniqueBeanException with beans using the @Order / @Priority annotation.
First finding = bug:
The method AnnotationAwareOrderComparator.getPriority calls directly getClass() on the given beanInstance. This leads to no priority at all as the Proxy class (JdkProxy) does not contain the annotation. The fix seems reasonably easy: Just use the AopUtils.getTargetClass(beanInstance) instead of getClass().
Second finding = just to clarify:
Not sure if both @Order and @Priority should be supported by this? Currently only @Priority or @Primary seems to be used to identify autowire candidates via the DefaultListableBeanFactory.determineAutowireCandidate. Is this the desired behavior or should also the @Order annotation be considered here? As far as i remember @Priority was first introduced to support @Order with the standard API, and later also used to identify Primary candidates?
As of 4.3, AnnotationAwareOrderComparator checks for the new DecoratingProxy interface, introspecting the decorated class behind a proxy as well. Interface-based Spring AOP proxy automatically expose this now, even behind multiple nested proxies.
With respect to @Order versus @Priority: This is actually intended... An order is just that: a sort order, whereas a priority also implies primary characteristics for the first element in the list. So in Spring terms, the use of @Priority kind of combines @Order with an @Primary marker for the first element.
Activity
spring-projects-issues commentedon Mar 18, 2016
Juergen Hoeller commented
As of 4.3,
AnnotationAwareOrderComparatorchecks for the newDecoratingProxyinterface, introspecting the decorated class behind a proxy as well. Interface-based Spring AOP proxy automatically expose this now, even behind multiple nested proxies.With respect to
@Orderversus@Priority: This is actually intended... An order is just that: a sort order, whereas a priority also implies primary characteristics for the first element in the list. So in Spring terms, the use of@Prioritykind of combines@Orderwith an@Primarymarker for the first element.Juergen