diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java index 860659cce20..2fa7986003d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java @@ -17,9 +17,6 @@ package org.springframework.boot.actuate.autoconfigure.web.reactive; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -32,6 +29,7 @@ import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWeb import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.util.ObjectUtils; /** * A {@link ManagementContextFactory} for reactive web applications. @@ -45,9 +43,9 @@ class ReactiveManagementContextFactory implements ManagementContextFactory { ApplicationContext parent, Class... configClasses) { AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext(); child.setParent(parent); - List> combinedClasses = new ArrayList<>(Arrays.asList(configClasses)); - combinedClasses.add(ReactiveWebServerAutoConfiguration.class); - child.register(combinedClasses.toArray(new Class[combinedClasses.size()])); + Class[] combinedClasses = ObjectUtils.addObjectToArray(configClasses, + ReactiveWebServerAutoConfiguration.class); + child.register(combinedClasses); registerReactiveWebServerFactory(parent, child); return child; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactoryTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactoryTests.java index 30e6e0e0292..78623ff38e1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactoryTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactoryTests.java @@ -41,15 +41,18 @@ public class ReactiveManagementContextFactoryTests { private AnnotationConfigReactiveWebServerApplicationContext parent = new AnnotationConfigReactiveWebServerApplicationContext(); @Test - public void createManagementContextShouldCreateChildContextWithConfigClasses() throws Exception { + public void createManagementContextShouldCreateChildContextWithConfigClasses() + throws Exception { this.parent.register(ParentConfiguration.class); this.parent.refresh(); - AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory.createManagementContext(this.parent, - TestConfiguration1.class, TestConfiguration2.class); + AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory + .createManagementContext(this.parent, TestConfiguration1.class, + TestConfiguration2.class); childContext.refresh(); assertThat(childContext.getBean(TestConfiguration1.class)).isNotNull(); assertThat(childContext.getBean(TestConfiguration2.class)).isNotNull(); - assertThat(childContext.getBean(ReactiveWebServerAutoConfiguration.class)).isNotNull(); + assertThat(childContext.getBean(ReactiveWebServerAutoConfiguration.class)) + .isNotNull(); } @Configuration diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 57c5c33c1bd..b3669488bc6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -410,8 +410,8 @@ public class SpringApplicationTests { ExampleReactiveWebConfig.class); application.setWebApplicationType(WebApplicationType.REACTIVE); this.context = application.run(); - assertThat(this.context).isInstanceOf( - AnnotationConfigReactiveWebServerApplicationContext.class); + assertThat(this.context) + .isInstanceOf(AnnotationConfigReactiveWebServerApplicationContext.class); } @Test