Skip to content

Commit 0cab7c8

Browse files
committed
Defer Sorting AuthorizationAdvisors
Invoking AnnotationAwareOrderComparator#sort while the AuthorizationAdvisors are still being computed causes those advisors to be eagerly instantiated, making components like ObservationRegistry ineligible for post processing. This commit defers the sorting of the advisors until after they are all fully instantiated and available in the application context. Closes gh-15658
1 parent 8272640 commit 0cab7c8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

core/src/main/java/org/springframework/security/authorization/method/AuthorizationAdvisorProxyFactory.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public static AuthorizationAdvisorProxyFactory withReactiveDefaults() {
146146
*/
147147
@Override
148148
public Object proxy(Object target) {
149+
AnnotationAwareOrderComparator.sort(this.advisors);
149150
if (target == null) {
150151
return null;
151152
}
@@ -170,7 +171,6 @@ public Object proxy(Object target) {
170171
*/
171172
public void setAdvisors(AuthorizationAdvisor... advisors) {
172173
this.advisors = new ArrayList<>(List.of(advisors));
173-
AnnotationAwareOrderComparator.sort(this.advisors);
174174
}
175175

176176
/**
@@ -182,7 +182,6 @@ public void setAdvisors(AuthorizationAdvisor... advisors) {
182182
*/
183183
public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
184184
this.advisors = new ArrayList<>(advisors);
185-
AnnotationAwareOrderComparator.sort(this.advisors);
186185
}
187186

188187
/**

0 commit comments

Comments
 (0)