Fix priority semantic
Commit 5fe8f52 introduced a support for @Priority as an alternative to
@Primary but it broke the semantic of the priority value. This commit
fixes this inconsistency.
As for @Order, the lowest value means the highest priority so if
several beans are candidates for injection, the one having the lowest
value will be used.
Issue: SPR-10548
This commit is contained in:
@@ -1136,7 +1136,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the candidate with the highest priority in the given set of beans.
|
||||
* Determine the candidate with the highest priority in the given set of beans. As
|
||||
* defined by the {@link org.springframework.core.Ordered} interface, the lowest
|
||||
* value has the highest priority.
|
||||
* @param candidateBeans a Map of candidate names and candidate instances
|
||||
* that match the required type
|
||||
* @param requiredType the target dependency type to match against
|
||||
@@ -1158,7 +1160,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
"Multiple beans found with the same priority ('" + highestPriority + "') " +
|
||||
"among candidates: " + candidateBeans.keySet());
|
||||
}
|
||||
else if (candidatePriority > highestPriority) {
|
||||
else if (candidatePriority < highestPriority) {
|
||||
highestPriorityBeanName = candidateBeanName;
|
||||
highestPriority = candidatePriority;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user