Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
import reactor.core.publisher.Sinks;

public abstract class BaseDuplexConnection implements DuplexConnection {
protected Sinks.Empty<Void> onClose = Sinks.empty();
protected final Sinks.Empty<Void> onClose = Sinks.empty();
protected final UnboundedProcessor sender = new UnboundedProcessor(onClose::tryEmitEmpty);

protected UnboundedProcessor sender = new UnboundedProcessor();

public BaseDuplexConnection() {
onClose().doFinally(s -> doOnClose()).subscribe();
}
public BaseDuplexConnection() {}

@Override
public void sendFrame(int streamId, ByteBuf frame) {
Expand All @@ -48,7 +45,7 @@ public final Mono<Void> onClose() {

@Override
public final void dispose() {
onClose.tryEmitEmpty();
doOnClose();
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions rsocket-test/src/main/java/io/rsocket/test/PingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Flux<Payload> pingPong(
BiFunction<RSocket, ? super Payload, ? extends Publisher<Payload>> interaction,
int count,
final Recorder histogram) {
return client
.flatMapMany(
return Flux.usingWhen(
client,
rsocket ->
Flux.range(1, count)
.flatMap(
Expand All @@ -78,7 +78,11 @@ Flux<Payload> pingPong(
histogram.recordValue(diff);
});
},
64))
64),
rsocket -> {
rsocket.dispose();
return rsocket.onClose();
})
.doOnError(Throwable::printStackTrace);
}
}