From f2d8ca8b3ac1b0421514a5a04471467936f6391f Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 26 Apr 2018 15:33:39 -0700 Subject: [PATCH] Fix failing NettyReactiveWebServerFactoryTests NettyReactiveWebServerFactoryTests.portInUseExceptionIsThrownWhenPortIsAlreadyInUse started failing on CI following this change in reactor netty: https://github.com/reactor/reactor-netty/commit/e6634c27f6e847b7a6998a1f642c0b7efdf0c610 Instead of a `BindException`, a `NativeIoException` is thrown. Since that Exception is for internal use only, we throw a generic `WebServerException` instead of the `PortInUseException`. --- .../netty/NettyReactiveWebServerFactoryTests.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java index f7ef66f4b69..d485064c7f7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java @@ -25,11 +25,10 @@ import reactor.ipc.netty.http.server.HttpServerOptions; import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests; -import org.springframework.boot.web.server.PortInUseException; +import org.springframework.boot.web.server.WebServerException; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.equalTo; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -48,15 +47,13 @@ public class NettyReactiveWebServerFactoryTests } @Test - public void portInUseExceptionIsThrownWhenPortIsAlreadyInUse() { + public void exceptionIsThrownWhenPortIsAlreadyInUse() { AbstractReactiveWebServerFactory factory = getFactory(); factory.setPort(0); this.webServer = factory.getWebServer(new EchoHandler()); this.webServer.start(); factory.setPort(this.webServer.getPort()); - this.thrown.expect(PortInUseException.class); - this.thrown.expectMessage( - equalTo("Port " + this.webServer.getPort() + " is already in use")); + this.thrown.expect(WebServerException.class); factory.getWebServer(new EchoHandler()).start(); }