Fixes requestChannel to ensure support of half-closed state #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug on the requester side and ensures that the requester is capable of handling requests when its publisher has already sent or received completion.
The Bug here is in the fact that RequestChannel on the requester side has 2 maps to track the state:
receivers
which is there to receive OnNext/OnError/OnComplete signalssenders
- requestChannel specific map to hold a subscription and receive the request/cancel signals from the remote.This means if one is absent and another is present - the stream is in the half-closed state.
Originally, we had that -> https://github.com/rsocket/rsocket-java/blob/develop/rsocket-core/src/main/java/io/rsocket/core/RSocketRequester.java#L562
which means that if there is no receiver - it is impossible to handle any frames even though the sender map contains handling subscriptions.
Due to the spec, there is a half-closed state when the responder may send incomplete, but the requester may still continue its stream and send onXXX signals along with being able to receive demand (requestN) and cancel frames.
OUTER PUBLISHER COMPLETED - INNER PUBLISHER CAN SEND
OUTER PUBLISHER CANCELLED - INNER PUBLISHER CAN SEND
INNER PUBLISHER COMPLETED - OUTER PUBLISHER CAN SEND
INNER PUBLISHER CANCELLED - the WHOLE CHAIN IS TERMINATED
Signed-off-by: Oleh Dokuka shadowgun@i.ua