From 0a54fb73fa069f35aa2a3813412883dc540d0c95 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Wed, 20 Mar 2019 17:54:04 -0700 Subject: [PATCH] Remove redundant include from WebFluxTypeExcludeFilter For webflux, security configuration is configured via a bean of type `SecurityWebFilterChain` and not `ServerHttpSecurity`. We would have changed the include to be `SecurityWebFilterChain` but the filter only applies to beans registered via component scanning and not those registered in `@Configuration` classes, making the includes redundant. See gh-16088 --- .../web/reactive/WebFluxTypeExcludeFilter.java | 12 ------------ .../web/reactive/WebFluxTypeExcludeFilterTests.java | 10 ---------- 2 files changed, 22 deletions(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java index cf1285ee8d2..83816ebd348 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java @@ -29,7 +29,6 @@ import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.GenericConverter; import org.springframework.stereotype.Controller; -import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.reactive.config.WebFluxConfigurer; @@ -44,9 +43,6 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter { private static final Set> DEFAULT_INCLUDES; - private static final String[] OPTIONAL_INCLUDES = { - "org.springframework.security.config.web.server.ServerHttpSecurity" }; - static { Set> includes = new LinkedHashSet<>(); includes.add(ControllerAdvice.class); @@ -55,14 +51,6 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter { includes.add(Converter.class); includes.add(GenericConverter.class); includes.add(WebExceptionHandler.class); - for (String optionalInclude : OPTIONAL_INCLUDES) { - try { - includes.add(ClassUtils.forName(optionalInclude, null)); - } - catch (Exception ex) { - // Ignore - } - } DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java index c5eef5aff7f..28b9bc9e2b9 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java @@ -25,7 +25,6 @@ import org.springframework.context.annotation.FilterType; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; -import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @@ -54,7 +53,6 @@ public class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleWeb.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, ExampleServerHttpSecurity.class)).isFalse(); } @Test @@ -67,7 +65,6 @@ public class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleWeb.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, ExampleServerHttpSecurity.class)).isFalse(); } @Test @@ -80,7 +77,6 @@ public class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleWeb.class)).isTrue(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, ExampleServerHttpSecurity.class)).isTrue(); } @Test @@ -93,7 +89,6 @@ public class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleWeb.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isFalse(); - assertThat(excludes(filter, ExampleServerHttpSecurity.class)).isFalse(); } @Test @@ -106,7 +101,6 @@ public class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleWeb.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, ExampleServerHttpSecurity.class)).isFalse(); } private boolean excludes(WebFluxTypeExcludeFilter filter, Class type) @@ -170,8 +164,4 @@ public class WebFluxTypeExcludeFilterTests { } - static class ExampleServerHttpSecurity extends ServerHttpSecurity { - - } - }