diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java index 199d3e6328b..0c6921167cf 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java @@ -80,7 +80,9 @@ public class DevToolsIntegrationTests { @After public void stopApplication() throws InterruptedException { - this.launchedApplication.stop(); + if (this.launchedApplication != null) { + this.launchedApplication.stop(); + } } @Test diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java index 29b8b3b25da..38249f20e16 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java @@ -40,12 +40,12 @@ abstract class RemoteApplicationLauncher implements ApplicationLauncher { throws Exception { LaunchedJvm applicationJvm = javaLauncher.launch("app", createApplicationClassPath(), "com.example.DevToolsTestApplication", - "--server.port=12345", "--spring.devtools.remote.secret=secret"); - awaitServerPort(applicationJvm.getStandardOut()); + "--server.port=0", "--spring.devtools.remote.secret=secret"); + int port = awaitServerPort(applicationJvm.getStandardOut()); LaunchedJvm remoteSpringApplicationJvm = javaLauncher.launch( "remote-spring-application", createRemoteSpringApplicationClassPath(), RemoteSpringApplication.class.getName(), - "--spring.devtools.remote.secret=secret", "http://localhost:12345"); + "--spring.devtools.remote.secret=secret", "http://localhost:" + port); awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut()); return new LaunchedApplication(new File("target/remote"), applicationJvm.getStandardOut(), applicationJvm.getStandardError(),