Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate ConnectionOperationQueue with proper exception #298

Merged
merged 3 commits into from
Oct 25, 2017

Conversation

dariuszseweryn
Copy link
Owner

@dariuszseweryn dariuszseweryn commented Oct 24, 2017

As long as the user is interested in the connection the ConnectionOperationQueue will check the DisconnectionRouterOutput for exceptions that cause disconnection. If this exception is emitted the ConnectionOperationQueue terminates itself with the emitted error. If the user unsubscribes from the RxBleDevice.establishConnection() then the ConnectionOperationQueue terminates itself with the BleDisconnectedException as it was before this change. Fixes #297

As long as the user is interested in the connection the `ConnectionOperationQueue` will check the `DisconnectionRouterOutput` for exceptions that cause disconnection. If this exception is emitted the `ConnectionOperationQueue` terminates itself with the emitted error. If the user unsubscribes from the `RxBleDevice.establishConnection()` then the `ConnectionOperationQueue` terminates itself with the `BleDisconnectedException` as it was before this change.
@dariuszseweryn dariuszseweryn added the bug Bug that is caused by the library label Oct 24, 2017
@dariuszseweryn dariuszseweryn added this to the 1.4.2 milestone Oct 24, 2017
@dariuszseweryn dariuszseweryn requested a review from uKL October 24, 2017 13:54
@dariuszseweryn dariuszseweryn changed the title Fix #297 Terminate ConnectionOperationQueue with proper exception Terminate ConnectionOperationQueue with proper exception Oct 24, 2017
.queue(operationDisconnect)
.subscribe(
Actions.empty(),
Actions.<Throwable>toAction1(Actions.empty())
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove empty line.

}
}),
disconnectionErrorOutputObservable = Observable.merge(
disconnectionErrorInputRelay,
adapterStateObservable
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have it extracted to emitErrorWhenAdapterIsDisabled or similar?

}
}),
disconnectionErrorOutputObservable = Observable.merge(
disconnectionErrorInputRelay,
adapterStateObservable
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it rely on the initial state as well?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Was not an issue till now. The DisconnectionRouter would not get created (@ConnectionScope) if the adapter is off

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

void onGattConnectionStateException(BleGattException disconnectedGattException) {
disconnectionErrorRelay.call(disconnectedGattException);
@Override
public Observable<BleException> asExactObservable() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does it mean 'asExactObservable'? :) 😃 Could the method say something about the behavior?

private final Future<?> runnableFuture;
private volatile boolean shouldRun = true;
private volatile BleDisconnectedException bleDisconnectedException = null;
private volatile BleException disconnectionException = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Effectively volatile is not required here because of synchronization. Having synchronized access guarantees that the other thread will read the value after the previous has written it.

@dariuszseweryn dariuszseweryn merged commit 562e1f0 into master Oct 25, 2017
@dariuszseweryn dariuszseweryn deleted the fix/issue_297_disconnection_routing branch October 25, 2017 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is caused by the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants