How to fix ErrorCallbackNotImplemented -> CancellationException: Disposed in reactive java?

Viewed 189
  1. I am running a test to see how the notification will be sent. It is sent and I get the test result STATUS: STATUS_OK
  2. GatewayRSocketClient created via protobuff rpc method
@Test
public void sendRequestToService() {
    
    RSocket socket = RSocketConnector
        .connectWith(TcpClientTransport.create("127.0.0.1", 7576))
        .block();
    
    Mono<GatewayResponse> res = new GatewayRSocketClient(socket)
        .requestResponse(GatewayRequest.newBuilder()
        .setMethod(Method.METHOD_POST)
        .setUri("/notification/save-token")
        .putParams("token", "12345678")
        .build());
    
    System.out.println("STATUS: " + res.block().getStatus());    
}

This is the method to be called and further down the chain until the message is sent to firebase

@Override
public Mono<GatewayResponse> requestResponse(GatewayRequest message, ByteBuf metadata)
{
    return serv.sendMessage(new NotificationDTO("first notification", Event.CREDITING, "1234567"))
        .map(res -> GatewayResponse.newBuilder()
        .setStatus(res ? Status.STATUS_OK : Status.STATUS_NOT_FOUND)
        .build());
}

The test is running successfully but I am getting a long stacktrace.

I have searched for solutions and without success. The flow is thrown and apparently because of the exception. How can this be fixed?

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.util.concurrent.CancellationException: Disposed
Caused by: java.util.concurrent.CancellationException: Disposed
    at io.rsocket.internal.UnboundedProcessor.dispose(UnboundedProcessor.java:550) ~[rsocket-core-1.1.1.jar:na]
    at io.rsocket.transport.netty.TcpDuplexConnection.doOnClose(TcpDuplexConnection.java:67) ~[rsocket-transport-netty-1.1.1.jar:na]
    at io.rsocket.internal.BaseDuplexConnection.lambda$new$0(BaseDuplexConnection.java:30) ~[rsocket-core-1.1.1.jar:na]

The problem is that the socket stops in the test, because the test ends and an exception is thrown because of this. The question is how to close the socket correctly. I don't see suitable methods on RSocket.

0 Answers
Related