2
0
Эх сурвалжийг харах

Sort ObjectPostProcessors prior to invoking them

Fixes gh-3572
Wallace Wadge 9 жил өмнө
parent
commit
a366489c3c

+ 6 - 2
config/src/main/java/org/springframework/security/config/annotation/SecurityConfigurerAdapter.java

@@ -15,11 +15,13 @@
  */
  */
 package org.springframework.security.config.annotation;
 package org.springframework.security.config.annotation;
 
 
+import org.springframework.core.GenericTypeResolver;
+import org.springframework.core.annotation.AnnotationAwareOrderComparator;
+
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
-import org.springframework.core.GenericTypeResolver;
-
 /**
 /**
  * A base class for {@link SecurityConfigurer} that allows subclasses to only implement
  * A base class for {@link SecurityConfigurer} that allows subclasses to only implement
  * the methods they are interested in. It also provides a mechanism for using the
  * the methods they are interested in. It also provides a mechanism for using the
@@ -27,6 +29,7 @@ import org.springframework.core.GenericTypeResolver;
  * that is being configured.
  * that is being configured.
  *
  *
  * @author Rob Winch
  * @author Rob Winch
+ * @author Wallace Wadge
  *
  *
  * @param <O> The Object being built by B
  * @param <O> The Object being built by B
  * @param <B> The Builder that is building O and is configured by
  * @param <B> The Builder that is building O and is configured by
@@ -112,6 +115,7 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
 
 
 		@SuppressWarnings({ "rawtypes", "unchecked" })
 		@SuppressWarnings({ "rawtypes", "unchecked" })
 		public Object postProcess(Object object) {
 		public Object postProcess(Object object) {
+			Collections.sort(postProcessors, AnnotationAwareOrderComparator.INSTANCE);
 			for (ObjectPostProcessor opp : postProcessors) {
 			for (ObjectPostProcessor opp : postProcessors) {
 				Class<?> oppClass = opp.getClass();
 				Class<?> oppClass = opp.getClass();
 				Class<?> oppType = GenericTypeResolver.resolveTypeArgument(oppClass,
 				Class<?> oppType = GenericTypeResolver.resolveTypeArgument(oppClass,