Skip to content

Commit 5bdbbdf

Browse files
committed
Require RSocket 1.0+
This commit removes the previously deprecated classes in Spring Framework 5.2.x. By doing so, Spring Framework now requires RSocket 1.0+. Closes gh-25548
1 parent 2087f35 commit 5bdbbdf

File tree

6 files changed

+9
-132
lines changed

6 files changed

+9
-132
lines changed

spring-messaging/src/main/java/org/springframework/messaging/rsocket/ClientRSocketFactoryConfigurer.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
8989

9090
private List<RSocketConnectorConfigurer> rsocketConnectorConfigurers = new ArrayList<>();
9191

92-
@SuppressWarnings("deprecation")
93-
private List<ClientRSocketFactoryConfigurer> rsocketFactoryConfigurers = new ArrayList<>();
94-
9592

9693
@Override
9794
public RSocketRequester.Builder dataMimeType(@Nullable MimeType mimeType) {
@@ -144,13 +141,6 @@ public RSocketRequester.Builder rsocketConnector(RSocketConnectorConfigurer conf
144141
return this;
145142
}
146143

147-
@Override
148-
@Deprecated
149-
public RSocketRequester.Builder rsocketFactory(ClientRSocketFactoryConfigurer configurer) {
150-
this.rsocketFactoryConfigurers.add(configurer);
151-
return this;
152-
}
153-
154144
@Override
155145
public RSocketRequester.Builder apply(Consumer<RSocketRequester.Builder> configurer) {
156146
configurer.accept(this);
@@ -180,7 +170,7 @@ public RSocketRequester transport(ClientTransport transport) {
180170
Mono<Payload> setupPayload = getSetupPayload(dataMimeType, metaMimeType, strategies);
181171

182172
RSocketConnector connector = initConnector(
183-
this.rsocketConnectorConfigurers, this.rsocketFactoryConfigurers,
173+
this.rsocketConnectorConfigurers,
184174
metaMimeType, dataMimeType, setupPayload, strategies);
185175

186176
return new DefaultRSocketRequester(
@@ -214,7 +204,7 @@ public Mono<RSocketRequester> connect(ClientTransport transport) {
214204
Mono<Payload> setupPayload = getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies);
215205

216206
RSocketConnector connector = initConnector(
217-
this.rsocketConnectorConfigurers, this.rsocketFactoryConfigurers,
207+
this.rsocketConnectorConfigurers,
218208
metaMimeType, dataMimeType, setupPayload, rsocketStrategies);
219209

220210
return connector.connect(transport).map(rsocket ->
@@ -304,19 +294,12 @@ private Mono<Payload> getSetupPayload(
304294

305295
@SuppressWarnings("deprecation")
306296
private RSocketConnector initConnector(List<RSocketConnectorConfigurer> connectorConfigurers,
307-
List<ClientRSocketFactoryConfigurer> factoryConfigurers,
308297
MimeType metaMimeType, MimeType dataMimeType, Mono<Payload> setupPayloadMono,
309298
RSocketStrategies rsocketStrategies) {
310299

311300
RSocketConnector connector = RSocketConnector.create();
312301
connectorConfigurers.forEach(c -> c.configure(connector));
313302

314-
if (!factoryConfigurers.isEmpty()) {
315-
io.rsocket.RSocketFactory.ClientRSocketFactory factory =
316-
new io.rsocket.RSocketFactory.ClientRSocketFactory(connector);
317-
factoryConfigurers.forEach(c -> c.configure(factory));
318-
}
319-
320303
if (rsocketStrategies.dataBufferFactory() instanceof NettyDataBufferFactory) {
321304
connector.payloadDecoder(PayloadDecoder.ZERO_COPY);
322305
}

spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ private DataBuffer encodeEntries(List<MetadataEntry> entries) {
184184
CompositeByteBuf composite = this.allocator.compositeBuffer();
185185
try {
186186
if (this.route != null) {
187-
io.rsocket.metadata.CompositeMetadataFlyweight.encodeAndAddMetadata(composite, this.allocator,
187+
io.rsocket.metadata.CompositeMetadataCodec.encodeAndAddMetadata(composite, this.allocator,
188188
WellKnownMimeType.MESSAGE_RSOCKET_ROUTING, encodeRoute());
189189
}
190190
entries.forEach(entry -> {
191191
Object value = entry.value();
192-
io.rsocket.metadata.CompositeMetadataFlyweight.encodeAndAddMetadata(
192+
io.rsocket.metadata.CompositeMetadataCodec.encodeAndAddMetadata(
193193
composite, this.allocator, entry.mimeType().toString(),
194194
value instanceof ByteBuf ? (ByteBuf) value : PayloadUtils.asByteBuf(encodeEntry(entry)));
195195
});
@@ -219,9 +219,8 @@ else if (this.route != null) {
219219
}
220220
}
221221

222-
@SuppressWarnings("deprecation")
223222
private ByteBuf encodeRoute() {
224-
return io.rsocket.metadata.TaggingMetadataFlyweight.createRoutingMetadata(
223+
return io.rsocket.metadata.TaggingMetadataCodec.createRoutingMetadata(
225224
this.allocator, Collections.singletonList(this.route)).getContent();
226225
}
227226

spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,6 @@ interface Builder {
215215
*/
216216
RSocketRequester.Builder rsocketConnector(RSocketConnectorConfigurer configurer);
217217

218-
/**
219-
* Callback to configure the {@code ClientRSocketFactory} directly.
220-
* <ul>
221-
* <li>The data and metadata mime types cannot be set directly
222-
* on the {@code ClientRSocketFactory} and will be overridden. Use the
223-
* shortcuts {@link #dataMimeType(MimeType)} and
224-
* {@link #metadataMimeType(MimeType)} on this builder instead.
225-
* <li>The frame decoder also cannot be set directly and instead is set
226-
* to match the configured {@code DataBufferFactory}.
227-
* <li>For the
228-
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory#setupPayload(Payload)
229-
* setupPayload}, consider using methods on this builder to specify the
230-
* route, other metadata, and data as Object values to be encoded.
231-
* <li>To configure client side responding, see
232-
* {@link RSocketMessageHandler#clientResponder(RSocketStrategies, Object...)}.
233-
* </ul>
234-
* @deprecated as of 5.2.6 following the deprecation of
235-
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
236-
* in RSocket 1.0 RC7. Please, use {@link #rsocketConnector(RSocketConnectorConfigurer)}.
237-
*/
238-
@Deprecated
239-
RSocketRequester.Builder rsocketFactory(ClientRSocketFactoryConfigurer configurer);
240-
241218
/**
242219
* Configure this builder through a {@code Consumer}. This enables
243220
* libraries such as Spring Security to provide shortcuts for applying

spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ protected CompositeMessageCondition extendMapping(CompositeMessageCondition comp
330330

331331
List<MessageCondition<?>> conditions = composite.getMessageConditions();
332332
Assert.isTrue(conditions.size() == 2 &&
333-
conditions.get(0) instanceof RSocketFrameTypeMessageCondition &&
334-
conditions.get(1) instanceof DestinationPatternsMessageCondition,
333+
conditions.get(0) instanceof RSocketFrameTypeMessageCondition &&
334+
conditions.get(1) instanceof DestinationPatternsMessageCondition,
335335
"Unexpected message condition types");
336336

337337
if (conditions.get(0) != RSocketFrameTypeMessageCondition.EMPTY_CONDITION) {
@@ -394,7 +394,7 @@ protected void handleNoMatch(@Nullable RouteMatcher.Route destination, Message<?
394394
* Return an RSocket {@link SocketAcceptor} backed by this
395395
* {@code RSocketMessageHandler} instance that can be plugged in as a
396396
* {@link io.rsocket.core.RSocketConnector#acceptor(SocketAcceptor) client} or
397-
* {@link io.rsocket.core.RSocketServer#acceptor(SocketAcceptor) server}
397+
* {@link io.rsocket.core.RSocketServer#acceptor(SocketAcceptor) server}
398398
* RSocket responder.
399399
* <p>The initial {@link ConnectionSetupPayload} is handled through
400400
* {@link ConnectMapping @ConnectionMapping} methods that can be asynchronous
@@ -494,45 +494,4 @@ public static SocketAcceptor responder(RSocketStrategies strategies, Object... c
494494
return handler.responder();
495495
}
496496

497-
/**
498-
* Static factory method for a configurer of a client side responder with
499-
* annotated handler methods. This is intended to be passed into
500-
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}.
501-
* <p>In effect a shortcut to create and initialize
502-
* {@code RSocketMessageHandler} with the given strategies and handlers.
503-
* Use {@link #responder()} to obtain the responder and plug that into
504-
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory ClientRSocketFactory}.
505-
* For more advanced scenarios, e.g. discovering handlers through a custom
506-
* stereotype annotation, consider declaring {@code RSocketMessageHandler}
507-
* as a bean, and then obtain the responder from it.
508-
* @param strategies the strategies to set on the created
509-
* {@code RSocketMessageHandler}
510-
* @param candidateHandlers a list of Objects and/or Classes with annotated
511-
* handler methods; used to call {@link #setHandlers(List)} on the created
512-
* {@code RSocketMessageHandler}
513-
* @return a configurer that may be passed into
514-
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}
515-
* @deprecated as of 5.2.6 following the deprecation of
516-
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
517-
* in RSocket 1.0 RC7
518-
*/
519-
@Deprecated
520-
@SuppressWarnings("deprecation")
521-
public static org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer clientResponder(
522-
RSocketStrategies strategies, Object... candidateHandlers) {
523-
524-
Assert.notEmpty(candidateHandlers, "No handlers");
525-
List<Object> handlers = new ArrayList<>(candidateHandlers.length);
526-
for (Object obj : candidateHandlers) {
527-
handlers.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj);
528-
}
529-
530-
return factory -> {
531-
RSocketMessageHandler handler = new RSocketMessageHandler();
532-
handler.setHandlers(handlers);
533-
handler.setRSocketStrategies(strategies);
534-
handler.afterPropertiesSet();
535-
factory.acceptor(handler.responder());
536-
};
537-
}
538497
}

spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,17 @@ public void setup() {
7979

8080

8181
@Test
82-
@SuppressWarnings({"unchecked", "deprecation"})
82+
@SuppressWarnings("unchecked")
8383
public void rsocketConnectorConfigurer() {
84-
ClientRSocketFactoryConfigurer factoryConfigurer = mock(ClientRSocketFactoryConfigurer.class);
8584
Consumer<RSocketStrategies.Builder> strategiesConfigurer = mock(Consumer.class);
8685
RSocketRequester.builder()
8786
.rsocketConnector(this.connectorConfigurer)
88-
.rsocketFactory(factoryConfigurer)
8987
.rsocketStrategies(strategiesConfigurer)
9088
.transport(this.transport);
9189

9290
// RSocketStrategies and RSocketConnector configurers should have been called
9391

9492
verify(strategiesConfigurer).accept(any(RSocketStrategies.Builder.class));
95-
verify(factoryConfigurer).configure(any(io.rsocket.RSocketFactory.ClientRSocketFactory.class));
9693
assertThat(this.connectorConfigurer.connector()).isNotNull();
9794
}
9895

0 commit comments

Comments
 (0)