소스 검색

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
Josh Cummings 1 년 전
부모
커밋
0cab7c8f15
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      core/src/main/java/org/springframework/security/authorization/method/AuthorizationAdvisorProxyFactory.java

+ 1 - 2
core/src/main/java/org/springframework/security/authorization/method/AuthorizationAdvisorProxyFactory.java

@@ -146,6 +146,7 @@ public final class AuthorizationAdvisorProxyFactory
 	 */
 	@Override
 	public Object proxy(Object target) {
+		AnnotationAwareOrderComparator.sort(this.advisors);
 		if (target == null) {
 			return null;
 		}
@@ -170,7 +171,6 @@ public final class AuthorizationAdvisorProxyFactory
 	 */
 	public void setAdvisors(AuthorizationAdvisor... advisors) {
 		this.advisors = new ArrayList<>(List.of(advisors));
-		AnnotationAwareOrderComparator.sort(this.advisors);
 	}
 
 	/**
@@ -182,7 +182,6 @@ public final class AuthorizationAdvisorProxyFactory
 	 */
 	public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
 		this.advisors = new ArrayList<>(advisors);
-		AnnotationAwareOrderComparator.sort(this.advisors);
 	}
 
 	/**