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
1 changed files with 7 additions and 3 deletions

View File

@ -15,10 +15,12 @@
*/
package org.springframework.security.config.annotation;
import java.util.ArrayList;
import java.util.List;
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
@ -27,6 +29,7 @@ import org.springframework.core.GenericTypeResolver;
* that is being configured.
*
* @author Rob Winch
* @author Wallace Wadge
*
* @param <O> The Object being built by B
* @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" })
public Object postProcess(Object object) {
Collections.sort(postProcessors, AnnotationAwareOrderComparator.INSTANCE);
for (ObjectPostProcessor opp : postProcessors) {
Class<?> oppClass = opp.getClass();
Class<?> oppType = GenericTypeResolver.resolveTypeArgument(oppClass,