Enable deprecation compilation warnings

See gh-21271
This commit is contained in:
Andy Wilkinson
2020-06-04 12:58:29 +01:00
parent c64649a6d9
commit 056d5f3120
47 changed files with 182 additions and 168 deletions

View File

@@ -24,8 +24,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import io.rsocket.RSocketFactory;
import io.rsocket.RSocketFactory.ServerRSocketFactory;
import io.rsocket.SocketAcceptor;
import io.rsocket.transport.ServerTransport;
import io.rsocket.transport.netty.server.CloseableChannel;
@@ -39,7 +37,6 @@ import org.springframework.boot.rsocket.server.ConfigurableRSocketServerFactory;
import org.springframework.boot.rsocket.server.RSocketServer;
import org.springframework.boot.rsocket.server.RSocketServerCustomizer;
import org.springframework.boot.rsocket.server.RSocketServerFactory;
import org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor;
import org.springframework.http.client.reactive.ReactorResourceFactory;
import org.springframework.util.Assert;
@@ -62,7 +59,8 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
private Duration lifecycleTimeout;
private List<ServerRSocketFactoryProcessor> socketFactoryProcessors = new ArrayList<>();
@SuppressWarnings("deprecation")
private List<org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> socketFactoryProcessors = new ArrayList<>();
private List<RSocketServerCustomizer> rSocketServerCustomizers = new ArrayList<>();
@@ -90,29 +88,32 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
}
/**
* Set {@link ServerRSocketFactoryProcessor}s that should be called to process the
* {@link ServerRSocketFactory} while building the server. Calling this method will
* replace any existing processors.
* 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 ServerRSocketFactoryProcessor> socketFactoryProcessors) {
Collection<? extends org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor> socketFactoryProcessors) {
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
this.socketFactoryProcessors = new ArrayList<>(socketFactoryProcessors);
}
/**
* Add {@link ServerRSocketFactoryProcessor}s that should be called to process the
* {@link ServerRSocketFactory} while building the server.
* 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(ServerRSocketFactoryProcessor... socketFactoryProcessors) {
public void addSocketFactoryProcessors(
org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor... socketFactoryProcessors) {
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
this.socketFactoryProcessors.addAll(Arrays.asList(socketFactoryProcessors));
}
@@ -154,7 +155,8 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
public NettyRSocketServer create(SocketAcceptor socketAcceptor) {
ServerTransport<CloseableChannel> transport = createTransport();
io.rsocket.core.RSocketServer server = io.rsocket.core.RSocketServer.create(socketAcceptor);
RSocketFactory.ServerRSocketFactory factory = new ServerRSocketFactory(server);
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);

View File

@@ -16,10 +16,9 @@
package org.springframework.boot.rsocket.server;
import io.rsocket.RSocketFactory.ServerRSocketFactory;
/**
* Processor that allows for custom modification of a {@link ServerRSocketFactory
* Processor that allows for custom modification of a
* {@link io.rsocket.RSocketFactory.ServerRSocketFactory
* RSocketFactory.ServerRSocketFactory} before it is used.
*
* @author Brian Clozel
@@ -37,6 +36,6 @@ public interface ServerRSocketFactoryProcessor {
* @param factory the factory to process
* @return the processed factory instance
*/
ServerRSocketFactory process(ServerRSocketFactory factory);
io.rsocket.RSocketFactory.ServerRSocketFactory process(io.rsocket.RSocketFactory.ServerRSocketFactory factory);
}

View File

@@ -25,7 +25,6 @@ import io.netty.buffer.PooledByteBufAllocator;
import io.rsocket.ConnectionSetupPayload;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.RSocketFactory;
import io.rsocket.SocketAcceptor;
import io.rsocket.transport.netty.client.WebsocketClientTransport;
import io.rsocket.util.DefaultPayload;
@@ -37,7 +36,6 @@ import reactor.core.publisher.Mono;
import org.springframework.boot.rsocket.server.RSocketServer;
import org.springframework.boot.rsocket.server.RSocketServerCustomizer;
import org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
@@ -131,20 +129,20 @@ class NettyRSocketServerFactoryTests {
}
@Test
@SuppressWarnings("deprecation")
@Deprecated
void serverProcessors() {
NettyRSocketServerFactory factory = getFactory();
ServerRSocketFactoryProcessor[] processors = new ServerRSocketFactoryProcessor[2];
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(ServerRSocketFactoryProcessor.class);
given(processors[i].process(any(RSocketFactory.ServerRSocketFactory.class)))
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 (ServerRSocketFactoryProcessor processor : processors) {
ordered.verify(processor).process(any(RSocketFactory.ServerRSocketFactory.class));
for (org.springframework.boot.rsocket.server.ServerRSocketFactoryProcessor processor : processors) {
ordered.verify(processor).process(any(io.rsocket.RSocketFactory.ServerRSocketFactory.class));
}
}
@@ -200,6 +198,7 @@ class NettyRSocketServerFactoryTests {
static class EchoRequestResponseAcceptor implements SocketAcceptor {
@Override
@SuppressWarnings("deprecation")
public Mono<RSocket> accept(ConnectionSetupPayload setupPayload, RSocket rSocket) {
return Mono.just(new RSocket() {
@Override