Skip to content

Unsubscribe from the connection before shutdown the RS.#107

Merged
NiteshKant merged 2 commits intomasterfrom
stevegury/dispose_on_close
Jun 28, 2016
Merged

Unsubscribe from the connection before shutdown the RS.#107
NiteshKant merged 2 commits intomasterfrom
stevegury/dispose_on_close

Conversation

@stevegury
Copy link
Copy Markdown
Member

Problem
When we close a ReactiveSocket, it closes the underlying DuplexConnection
which trigger an unnecessary onError on the Requester/Responder.

Solution
Store the disposable of the DuplexConnection subscription as an instance
variable, and dispose it before closing the DuplexConnection.

Modification
I also added a name method in Requester/Responder to simplify debugging
code where we have client and server in the same JVM.
It now shows which Requester/Responder is generating an error, the client's
one or the server's one.

**Problem**
When we close a ReactiveSocket, it closes the underlying DuplexConnection
which trigger an unnecessary onError on the Requester/Responder.

**Solution**
Store the disposable of the DuplexConnection subscription as an instance
variable, and dispose it before closing the DuplexConnection.

**Modification**
I also added a `name` method in Requester/Responder to simplify debugging
code where we have client and server in the same JVM.
It now shows which Requester/Responder is generating an error, the client's
one or the server's one.
public void shutdown() {
// TODO do something here
System.err.println("**** Requester.shutdown => this should actually do something");
Disposable disposable = connectionSubscription.getAndSet(CANCELLED);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: EmptyDisposable (CANCELLED here) ignores dispose call, so you don't need && disposable != CANCELLED check here.

@NiteshKant NiteshKant merged commit ef2f9f7 into master Jun 28, 2016
@NiteshKant NiteshKant modified the milestone: 0.2.2 Jun 28, 2016
This was referenced Jun 28, 2016
@stevegury stevegury deleted the stevegury/dispose_on_close branch June 30, 2016 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants