Skip to content

Commit

Permalink
Defer Sorting AuthorizationAdvisors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jzheaux committed Aug 20, 2024
1 parent 8272640 commit 0cab7c8
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static AuthorizationAdvisorProxyFactory withReactiveDefaults() {
*/
@Override
public Object proxy(Object target) {
AnnotationAwareOrderComparator.sort(this.advisors);
if (target == null) {
return null;
}
Expand All @@ -170,7 +171,6 @@ public Object proxy(Object target) {
*/
public void setAdvisors(AuthorizationAdvisor... advisors) {
this.advisors = new ArrayList<>(List.of(advisors));
AnnotationAwareOrderComparator.sort(this.advisors);
}

/**
Expand All @@ -182,7 +182,6 @@ public void setAdvisors(AuthorizationAdvisor... advisors) {
*/
public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
this.advisors = new ArrayList<>(advisors);
AnnotationAwareOrderComparator.sort(this.advisors);
}

/**
Expand Down

0 comments on commit 0cab7c8

Please sign in to comment.