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

Prepare DisconnectionRouter for concurrent access. #442

Merged
merged 1 commit into from Jun 13, 2018

Conversation

dariuszseweryn
Copy link
Owner

DisconnectionRouter is storing emitters waiting for information about disconnection in a Queue. This Queue may be accessed concurrently and it was not prepared for this scenario. Additionally there could be a race if an exception would happen when a new emitter would get subscribed.
Fixes #441

DisconnectionRouter is storing emitters waiting for information about disconnection in a Queue. This Queue may be accessed concurrently and it was not prepared for this scenario. Additionally there could be a race if an exception would happen when a new emitter would get subscribed.
Fixes #441
@dariuszseweryn dariuszseweryn added the bug Bug that is caused by the library label Jun 13, 2018
@dariuszseweryn dariuszseweryn added this to the 1.7.0 milestone Jun 13, 2018
@dariuszseweryn dariuszseweryn self-assigned this Jun 13, 2018
@dariuszseweryn dariuszseweryn requested a review from uKL June 13, 2018 10:46
@@ -107,7 +107,7 @@ public void onGattConnectionStateException(BleGattException disconnectedGattExce
onExceptionOccurred(disconnectedGattException);
}

private void onExceptionOccurred(BleException exception) {
private synchronized void onExceptionOccurred(BleException exception) {
if (exceptionOccurred == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we could use AtomicReference instead?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure if this would be sufficient for this use-case as the race may if a new observer is subscribing to asValueOnlyObservable after the check for exceptionOccured is made

@dariuszseweryn dariuszseweryn merged commit b4c771a into master Jun 13, 2018
@dariuszseweryn dariuszseweryn deleted the fix/concurrency_disconnection_router branch June 13, 2018 13:33
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.

None yet

2 participants