Polishing and minor refactoring

See gh-25884
This commit is contained in:
Rossen Stoyanchev
2020-10-12 11:32:48 +01:00
parent 66138f0dce
commit 5b1b20c8c0
12 changed files with 56 additions and 59 deletions

View File

@@ -75,7 +75,7 @@ public class ReactorNettyTcpConnection<P> implements TcpConnection<P> {
@Override
public void close() {
// Ignore result: can't overflow, ok if not first or no one listens
// Ignore result: concurrent attempts to complete are ok
this.completionSink.tryEmitEmpty();
}

View File

@@ -200,10 +200,12 @@ class RSocketServerToClientIntegrationTests {
private void runTest(Runnable testEcho) {
Mono.fromRunnable(testEcho)
.doOnError(ex -> resultSink.emitError(ex, Sinks.EmitFailureHandler.FAIL_FAST))
.doOnSuccess(o -> resultSink.emitEmpty(Sinks.EmitFailureHandler.FAIL_FAST))
.subscribeOn(Schedulers.boundedElastic()) // StepVerifier will block
.subscribe();
.subscribe(
aVoid -> {},
ex -> resultSink.tryEmitError(ex), // Ignore result: signals cannot compete
() -> resultSink.tryEmitEmpty()
);
}
@MessageMapping("fnf")
@@ -218,7 +220,7 @@ class RSocketServerToClientIntegrationTests {
@MessageMapping("receive")
void receive(String payload) {
this.fireForgetPayloads.tryEmitNext(payload);
this.fireForgetPayloads.emitNext(payload, Sinks.EmitFailureHandler.FAIL_FAST);
}
@MessageMapping("echo")

View File

@@ -341,8 +341,8 @@ public class SimpAnnotationMethodMessageHandlerTests {
Message<?> message = createMessage("/app1/mono");
this.messageHandler.handleMessage(message);
assertThat(controller.oneSink).isNotNull();
controller.oneSink.emitValue("foo", Sinks.EmitFailureHandler.FAIL_FAST);
assertThat(controller.sinkOne).isNotNull();
controller.sinkOne.emitValue("foo", Sinks.EmitFailureHandler.FAIL_FAST);
verify(this.converter).toMessage(this.payloadCaptor.capture(), any(MessageHeaders.class));
assertThat(this.payloadCaptor.getValue()).isEqualTo("foo");
}
@@ -356,7 +356,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
Message<?> message = createMessage("/app1/mono");
this.messageHandler.handleMessage(message);
controller.oneSink.emitError(new IllegalStateException(), Sinks.EmitFailureHandler.FAIL_FAST);
controller.sinkOne.emitError(new IllegalStateException(), Sinks.EmitFailureHandler.FAIL_FAST);
assertThat(controller.exceptionCaught).isTrue();
}
@@ -369,8 +369,8 @@ public class SimpAnnotationMethodMessageHandlerTests {
Message<?> message = createMessage("/app1/flux");
this.messageHandler.handleMessage(message);
assertThat(controller.manySink).isNotNull();
controller.manySink.tryEmitNext("foo");
assertThat(controller.sinkMany).isNotNull();
controller.sinkMany.tryEmitNext("foo");
verify(this.converter, never()).toMessage(any(), any(MessageHeaders.class));
}
@@ -584,22 +584,22 @@ public class SimpAnnotationMethodMessageHandlerTests {
@Controller
private static class ReactiveController {
private Sinks.One<String> oneSink;
private Sinks.One<String> sinkOne;
private Sinks.Many<String> manySink;
private Sinks.Many<String> sinkMany;
private boolean exceptionCaught = false;
@MessageMapping("mono")
public Mono<String> handleMono() {
this.oneSink = Sinks.one();
return this.oneSink.asMono();
this.sinkOne = Sinks.one();
return this.sinkOne.asMono();
}
@MessageMapping("flux")
public Flux<String> handleFlux() {
this.manySink = Sinks.many().unicast().onBackpressureBuffer();
return this.manySink.asFlux();
this.sinkMany = Sinks.many().unicast().onBackpressureBuffer();
return this.sinkMany.asFlux();
}
@MessageExceptionHandler(IllegalStateException.class)