diff --git a/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfiguration.java b/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfiguration.java index de829c109d8..225c9eff22c 100644 --- a/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfiguration.java +++ b/module/spring-boot-rsocket/src/main/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfiguration.java @@ -150,7 +150,7 @@ public final class RSocketServerAutoConfiguration { } - @ConditionalOnProperty(name = "spring.rsocket.server.port", matchIfMissing = true) + @ConditionalOnProperty(name = "spring.rsocket.server.port", havingValue = "false", matchIfMissing = true) static class HasNoPortConfigured { } diff --git a/module/spring-boot-rsocket/src/test/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfigurationTests.java b/module/spring-boot-rsocket/src/test/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfigurationTests.java index 246ac319e23..c20f5067f2f 100644 --- a/module/spring-boot-rsocket/src/test/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfigurationTests.java +++ b/module/spring-boot-rsocket/src/test/java/org/springframework/boot/rsocket/autoconfigure/RSocketServerAutoConfigurationTests.java @@ -84,6 +84,17 @@ class RSocketServerAutoConfigurationTests { .run((context) -> assertThat(context).hasSingleBean(RSocketWebSocketNettyRouteProvider.class)); } + @Test + void shouldNotCreateWebSocketRouteProviderWhenDedicatedPortIsSet() { + reactiveWebContextRunner() + .withPropertyValues("spring.rsocket.server.port=0", "spring.rsocket.server.transport=websocket", + "spring.rsocket.server.mapping-path=/rsocket") + .run((context) -> { + assertThat(context).hasSingleBean(RSocketServerFactory.class); + assertThat(context).doesNotHaveBean(RSocketWebSocketNettyRouteProvider.class); + }); + } + @Test void shouldCreateDefaultBeansForRSocketServerWhenPortIsSet() { reactiveWebContextRunner().withPropertyValues("spring.rsocket.server.port=0")