Require RSocket 1.0+

This commit removes usage of methods and classes that were previously
deprecated in RSocket and Spring Framework and have been removed.

Closes gh-22764
This commit is contained in:
Brian Clozel
2020-08-06 16:09:36 +02:00
parent 4b17bfd889
commit 4ef08425e6
10 changed files with 6 additions and 135 deletions

View File

@@ -155,9 +155,8 @@ public class IntegrationAutoConfiguration {
/**
* Integration RSocket configuration.
*/
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ IntegrationRSocketEndpoint.class, RSocketRequester.class, io.rsocket.RSocketFactory.class })
@ConditionalOnClass({ IntegrationRSocketEndpoint.class, RSocketRequester.class, io.rsocket.RSocket.class })
@Conditional(IntegrationRSocketConfiguration.AnyRSocketChannelAdapterAvailable.class)
protected static class IntegrationRSocketConfiguration {

View File

@@ -36,9 +36,8 @@ import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHa
* @author Brian Clozel
* @since 2.2.0
*/
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ RSocketRequester.class, io.rsocket.RSocketFactory.class, TcpServerTransport.class })
@ConditionalOnClass({ RSocketRequester.class, io.rsocket.RSocket.class, TcpServerTransport.class })
@AutoConfigureAfter(RSocketStrategiesAutoConfiguration.class)
public class RSocketMessagingAutoConfiguration {

View File

@@ -39,10 +39,8 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
* @author Brian Clozel
* @since 2.2.0
*/
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ RSocketRequester.class, io.rsocket.RSocketFactory.class, HttpServer.class,
TcpServerTransport.class })
@ConditionalOnClass({ RSocketRequester.class, io.rsocket.RSocket.class, HttpServer.class, TcpServerTransport.class })
@AutoConfigureAfter(RSocketStrategiesAutoConfiguration.class)
public class RSocketRequesterAutoConfiguration {

View File

@@ -69,13 +69,10 @@ public class RSocketServerAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@SuppressWarnings("deprecation")
RSocketWebSocketNettyRouteProvider rSocketWebsocketRouteProvider(RSocketProperties properties,
RSocketMessageHandler messageHandler,
ObjectProvider<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> processors,
ObjectProvider<RSocketServerCustomizer> customizers) {
RSocketMessageHandler messageHandler, ObjectProvider<RSocketServerCustomizer> customizers) {
return new RSocketWebSocketNettyRouteProvider(properties.getServer().getMappingPath(),
messageHandler.responder(), processors.orderedStream(), customizers.orderedStream());
messageHandler.responder(), customizers.orderedStream());
}
}
@@ -92,9 +89,7 @@ public class RSocketServerAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@SuppressWarnings("deprecation")
RSocketServerFactory rSocketServerFactory(RSocketProperties properties, ReactorResourceFactory resourceFactory,
ObjectProvider<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> processors,
ObjectProvider<RSocketServerCustomizer> customizers) {
NettyRSocketServerFactory factory = new NettyRSocketServerFactory();
factory.setResourceFactory(resourceFactory);
@@ -103,7 +98,6 @@ public class RSocketServerAutoConfiguration {
map.from(properties.getServer().getAddress()).to(factory::setAddress);
map.from(properties.getServer().getPort()).to(factory::setPort);
factory.setRSocketServerCustomizers(customizers.orderedStream().collect(Collectors.toList()));
factory.setSocketFactoryProcessors(processors.orderedStream().collect(Collectors.toList()));
return factory;
}

View File

@@ -47,9 +47,8 @@ import org.springframework.web.util.pattern.PathPatternRouteMatcher;
* @author Brian Clozel
* @since 2.2.0
*/
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ io.rsocket.RSocketFactory.class, RSocketStrategies.class, PooledByteBufAllocator.class })
@ConditionalOnClass({ io.rsocket.RSocket.class, RSocketStrategies.class, PooledByteBufAllocator.class })
@AutoConfigureAfter(JacksonAutoConfiguration.class)
public class RSocketStrategiesAutoConfiguration {

View File

@@ -34,32 +34,24 @@ import org.springframework.boot.web.embedded.netty.NettyRouteProvider;
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
class RSocketWebSocketNettyRouteProvider implements NettyRouteProvider {
private final String mappingPath;
private final SocketAcceptor socketAcceptor;
private final List<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> processors;
private final List<RSocketServerCustomizer> customizers;
RSocketWebSocketNettyRouteProvider(String mappingPath, SocketAcceptor socketAcceptor,
Stream<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> processors,
Stream<RSocketServerCustomizer> customizers) {
this.mappingPath = mappingPath;
this.socketAcceptor = socketAcceptor;
this.processors = processors.collect(Collectors.toList());
this.customizers = customizers.collect(Collectors.toList());
}
@Override
public HttpServerRoutes apply(HttpServerRoutes httpServerRoutes) {
RSocketServer server = RSocketServer.create(this.socketAcceptor);
io.rsocket.RSocketFactory.ServerRSocketFactory factory = new io.rsocket.RSocketFactory.ServerRSocketFactory(
server);
this.processors.forEach((processor) -> processor.process(factory));
this.customizers.forEach((customizer) -> customizer.customize(server));
ServerTransport.ConnectionAcceptor connectionAcceptor = server.asConnectionAcceptor();
return httpServerRoutes.ws(this.mappingPath, WebsocketRouteTransport.newHandler(connectionAcceptor));

View File

@@ -75,7 +75,6 @@ class RSocketWebSocketNettyRouteProviderTests {
WebTestClient client = createWebTestClient(serverContext.getWebServer());
client.get().uri("/protocol").exchange().expectStatus().isOk().expectBody().jsonPath("name",
"http");
assertThat(WebConfiguration.processorCallCount).isEqualTo(1);
});
}
@@ -93,8 +92,6 @@ class RSocketWebSocketNettyRouteProviderTests {
@Configuration(proxyBeanMethods = false)
static class WebConfiguration {
static int processorCallCount = 0;
@Bean
WebController webController() {
return new WebController();
@@ -107,15 +104,6 @@ class RSocketWebSocketNettyRouteProviderTests {
return serverFactory;
}
@Bean
@SuppressWarnings("deprecation")
org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor myRSocketFactoryProcessor() {
return (server) -> {
processorCallCount++;
return server;
};
}
}
@Controller

View File

@@ -59,9 +59,6 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
private Duration lifecycleTimeout;
@SuppressWarnings("deprecation")
private List<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> socketFactoryProcessors = new ArrayList<>();
private List<RSocketServerCustomizer> rSocketServerCustomizers = new ArrayList<>();
@Override
@@ -87,37 +84,6 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
this.resourceFactory = resourceFactory;
}
/**
* Set {@link org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor}s
* that should be called to process the
* {@link io.rsocket.RSocketFactory.ServerRSocketFactory} while building the server.
* Calling this method will replace any existing processors.
* @param socketFactoryProcessors processors to apply before the server starts
* @deprecated in favor of {@link #setRSocketServerCustomizers(Collection)} as of
* 2.2.7
*/
@Deprecated
public void setSocketFactoryProcessors(
Collection<? extends org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> socketFactoryProcessors) {
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
this.socketFactoryProcessors = new ArrayList<>(socketFactoryProcessors);
}
/**
* Add {@link org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor}s
* that should be called to process the
* {@link io.rsocket.RSocketFactory.ServerRSocketFactory} while building the server.
* @param socketFactoryProcessors processors to apply before the server starts
* @deprecated in favor of
* {@link #addRSocketServerCustomizers(RSocketServerCustomizer...)} as of 2.2.7
*/
@Deprecated
public void addSocketFactoryProcessors(
org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor... socketFactoryProcessors) {
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
this.socketFactoryProcessors.addAll(Arrays.asList(socketFactoryProcessors));
}
/**
* Set {@link RSocketServerCustomizer}s that should be called to configure the
* {@link io.rsocket.core.RSocketServer} while building the server. Calling this
@@ -151,14 +117,10 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
}
@Override
@SuppressWarnings("deprecation")
public NettyRSocketServer create(SocketAcceptor socketAcceptor) {
ServerTransport<CloseableChannel> transport = createTransport();
io.rsocket.core.RSocketServer server = io.rsocket.core.RSocketServer.create(socketAcceptor);
io.rsocket.RSocketFactory.ServerRSocketFactory factory = new io.rsocket.RSocketFactory.ServerRSocketFactory(
server);
this.rSocketServerCustomizers.forEach((customizer) -> customizer.customize(server));
this.socketFactoryProcessors.forEach((processor) -> processor.process(factory));
Mono<CloseableChannel> starter = server.bind(transport);
return new NettyRSocketServer(starter, this.lifecycleTimeout);
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.rsocket.server;
/**
* Processor that allows for custom modification of a
* {@link io.rsocket.RSocketFactory.ServerRSocketFactory
* RSocketFactory.ServerRSocketFactory} before it is used.
*
* @author Brian Clozel
* @see RSocketServerFactory
* @since 2.2.0
* @deprecated in favor of {@link RSocketServerCustomizer} as of 2.2.7
*/
@FunctionalInterface
@Deprecated
public interface ServerRSocketFactoryProcessor {
/**
* Apply this {@code ServerRSocketFactoryProcessor} to the given factory instance
* before it's used.
* @param factory the factory to process
* @return the processed factory instance
*/
io.rsocket.RSocketFactory.ServerRSocketFactory process(io.rsocket.RSocketFactory.ServerRSocketFactory factory);
}

View File

@@ -46,7 +46,6 @@ import org.springframework.util.SocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.will;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -128,24 +127,6 @@ class NettyRSocketServerFactoryTests {
assertThat(response).isEqualTo(payload);
}
@Test
@Deprecated
void serverProcessors() {
NettyRSocketServerFactory factory = getFactory();
org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor[] processors = new org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor[2];
for (int i = 0; i < processors.length; i++) {
processors[i] = mock(org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor.class);
given(processors[i].process(any(io.rsocket.RSocketFactory.ServerRSocketFactory.class)))
.will((invocation) -> invocation.getArgument(0));
}
factory.setSocketFactoryProcessors(Arrays.asList(processors));
this.server = factory.create(new EchoRequestResponseAcceptor());
InOrder ordered = inOrder((Object[]) processors);
for (org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor processor : processors) {
ordered.verify(processor).process(any(io.rsocket.RSocketFactory.ServerRSocketFactory.class));
}
}
@Test
void serverCustomizers() {
NettyRSocketServerFactory factory = getFactory();