Skip to content

Commit 195f933

Browse files
committed
Allow Default Ordering for TargetVisitor
In tests, we want to both test that functionality works and also demonstrate common or expected usage, where possible. It is likely incorrect to use @order(0) for a target visitor as this states that it should take precedence over all Spring Security visitors defined at a lower precedence. Also, it appears this may have been added this way because of a mock visitor that appears to be unused by any tests. Further, when an application has multiple visitors, they should use the TargetVisitor.of method to publish one bean with the order determined by the order of the method parameters instead of having two separate beans. This commit removes the @order(0) annotation and also the mock visitor, deferring to the natural ordering afforded by the framework. Issue gh-15994
1 parent ada75e7 commit 195f933

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

config/src/test/java/org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfigurationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.junit.jupiter.api.extension.ExtendWith;
4141
import org.junit.jupiter.params.ParameterizedTest;
4242
import org.junit.jupiter.params.provider.ValueSource;
43-
import org.mockito.Mockito;
4443

4544
import org.springframework.aop.Advisor;
4645
import org.springframework.aop.Pointcut;
@@ -1831,8 +1830,8 @@ static class AuthorizeResultConfig {
18311830

18321831
@Bean
18331832
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
1834-
static TargetVisitor customTargetVisitor() {
1835-
return TargetVisitor.of(Mockito.mock(), TargetVisitor.defaultsSkipValueTypes());
1833+
static TargetVisitor skipValueTypes() {
1834+
return TargetVisitor.defaultsSkipValueTypes();
18361835
}
18371836

18381837
@Bean

0 commit comments

Comments
 (0)