From c1691f525a7b85ed03eb70375ec2bbfed6e25ed1 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Fri, 18 Nov 2022 12:00:00 +0100 Subject: [PATCH 1/2] Polish SecurityProperties See gh-33251 --- .../boot/autoconfigure/security/SecurityProperties.java | 6 ++---- .../security/servlet/SecurityAutoConfigurationTests.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java index 4ad92e79fb..c3d5fcdd3f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java @@ -17,8 +17,7 @@ package org.springframework.boot.autoconfigure.security; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; +import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.UUID; @@ -83,8 +82,7 @@ public class SecurityProperties { /** * Security filter chain dispatcher types. */ - private Set dispatcherTypes = new HashSet<>(Arrays.asList(DispatcherType.ASYNC, - DispatcherType.ERROR, DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE)); + private Set dispatcherTypes = EnumSet.allOf(DispatcherType.class); public int getOrder() { return this.order; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java index 264d8d33c4..6c1aa5d731 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.autoconfigure.security.servlet; import java.security.interfaces.RSAPublicKey; +import java.util.EnumSet; import jakarta.servlet.DispatcherType; import org.assertj.core.api.InstanceOfAssertFactories; @@ -161,8 +162,7 @@ class SecurityAutoConfigurationTests { DelegatingFilterProxyRegistrationBean.class); assertThat(bean) .extracting("dispatcherTypes", InstanceOfAssertFactories.iterable(DispatcherType.class)) - .containsOnly(DispatcherType.ASYNC, DispatcherType.ERROR, DispatcherType.REQUEST, - DispatcherType.INCLUDE, DispatcherType.FORWARD); + .containsOnly(EnumSet.allOf(DispatcherType.class).toArray(new DispatcherType[0])); }); } From 98171921da909f6749eabed66f5d42d1d77158fa Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 18 Nov 2022 12:39:59 +0000 Subject: [PATCH 2/2] Polish "Polish SecurityProperties" See gh-33251 --- .../security/servlet/SecurityAutoConfigurationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java index 6c1aa5d731..12d59ce180 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java @@ -162,7 +162,7 @@ class SecurityAutoConfigurationTests { DelegatingFilterProxyRegistrationBean.class); assertThat(bean) .extracting("dispatcherTypes", InstanceOfAssertFactories.iterable(DispatcherType.class)) - .containsOnly(EnumSet.allOf(DispatcherType.class).toArray(new DispatcherType[0])); + .containsExactlyInAnyOrderElementsOf(EnumSet.allOf(DispatcherType.class)); }); }