Sort ObjectPostProcessors prior to invoking them

Fixes gh-3572
This commit is contained in:
Wallace Wadge 2016-03-05 09:04:24 +01:00 committed by Rob Winch
parent 3bbcbaae9c
commit a366489c3c

View File

@ -15,10 +15,12 @@
*/ */
package org.springframework.security.config.annotation; package org.springframework.security.config.annotation;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.GenericTypeResolver; import org.springframework.core.GenericTypeResolver;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* A base class for {@link SecurityConfigurer} that allows subclasses to only implement * A base class for {@link SecurityConfigurer} that allows subclasses to only implement
@ -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,