From 16f798dc11ffec4fe868fe126ffc4eab88773d9e Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 12 Aug 2019 21:11:59 +0200 Subject: [PATCH] Apply RSocket transport configuration on server Fixes gh-17845 --- .../autoconfigure/rsocket/RSocketProperties.java | 13 ++++--------- .../rsocket/RSocketServerAutoConfiguration.java | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketProperties.java index 4904fde65d..792d63cf8d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketProperties.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.rsocket; import java.net.InetAddress; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.rsocket.server.RSocketServer; /** * {@link ConfigurationProperties properties} for RSocket support. @@ -50,7 +51,7 @@ public class RSocketProperties { /** * RSocket transport protocol. */ - private Transport transport = Transport.TCP; + private RSocketServer.TRANSPORT transport = RSocketServer.TRANSPORT.TCP; /** * Path under which RSocket handles requests (only works with websocket @@ -74,11 +75,11 @@ public class RSocketProperties { this.address = address; } - public Transport getTransport() { + public RSocketServer.TRANSPORT getTransport() { return this.transport; } - public void setTransport(Transport transport) { + public void setTransport(RSocketServer.TRANSPORT transport) { this.transport = transport; } @@ -90,12 +91,6 @@ public class RSocketProperties { this.mappingPath = mappingPath; } - public enum Transport { - - TCP, WEBSOCKET - - } - } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java index a4abc17e45..3df1e33bc4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java @@ -92,6 +92,7 @@ public class RSocketServerAutoConfiguration { ObjectProvider customizers) { NettyRSocketServerFactory factory = new NettyRSocketServerFactory(); factory.setResourceFactory(resourceFactory); + factory.setTransport(properties.getServer().getTransport()); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(properties.getServer().getAddress()).to(factory::setAddress); map.from(properties.getServer().getPort()).to(factory::setPort);