Skip to content

Commit eb03144

Browse files
committed
RSocketRequester implements Disposable
Closes gh-26886
1 parent 29790d5 commit eb03144

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import io.rsocket.transport.netty.client.TcpClientTransport;
3131
import io.rsocket.transport.netty.client.WebsocketClientTransport;
3232
import org.reactivestreams.Publisher;
33+
import reactor.core.Disposable;
3334
import reactor.core.publisher.Flux;
3435
import reactor.core.publisher.Mono;
3536

@@ -49,7 +50,7 @@
4950
* @author Brian Clozel
5051
* @since 5.2
5152
*/
52-
public interface RSocketRequester {
53+
public interface RSocketRequester extends Disposable {
5354

5455
/**
5556
* Return the underlying {@link RSocketClient} used to make requests with.
@@ -110,6 +111,27 @@ public interface RSocketRequester {
110111
*/
111112
RequestSpec metadata(Object metadata, @Nullable MimeType mimeType);
112113

114+
/**
115+
* Shortcut method that delegates to the same on the underlying
116+
* {@link #rsocketClient()} in order to close the connection from the
117+
* underlying transport and notify subscribers.
118+
* @since 5.3.7
119+
*/
120+
@Override
121+
default void dispose() {
122+
rsocketClient().dispose();
123+
}
124+
125+
/**
126+
* Shortcut method that delegates to the same on the underlying
127+
* {@link #rsocketClient()}.
128+
* @since 5.3.7
129+
*/
130+
@Override
131+
default boolean isDisposed() {
132+
return rsocketClient().isDisposed();
133+
}
134+
113135
/**
114136
* Obtain a builder to create a client {@link RSocketRequester} by connecting
115137
* to an RSocket server.

0 commit comments

Comments
 (0)