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

Avoid interruption exception in tryAcquire when there is no wait. #428

Closed
wants to merge 1 commit into from

Conversation

visualage
Copy link
Contributor

When using the mongo-java-driver-reactivestream with RxJava2, sometimes the driver throws MongoInterruptedException due to RxJava2 interrupts the thread when disposed. See discussion on the RxJava2 side: ReactiveX/RxJava#5711

RxJava developers recommend the callbacks should not be interrupt sensitive. By changing the tryAcquire(0, TimeUnit) to tryAcquire(), it would not throw InterruptedException.

@rozza
Copy link
Member

rozza commented Nov 13, 2017

Hi @visualage,

Thanks for the ticket. I've added JAVA-2661 to track this.

Ross

@rozza
Copy link
Member

rozza commented Nov 13, 2017

@visualage it would be good to understand more about the error and if it is only triggered when calling tryAcquire(0, TimeUnit) . Could you provide some more information about triggering this error?

@rozza
Copy link
Member

rozza commented Nov 13, 2017

Double checking the RxJava2 thread, it looks like ReactiveX/RxJava#5715 fixes ReactiveX/RxJava#5711- can you confirm @visualage ?

@72MiguelGomes
Copy link

@rozza Not sure what error @visualage is trying to solve but it seems total sense if the timeout is 0 try to lock or return immediately. And it is also part of a function documentation:

timeout negative - forever 0 - return immediately no matter what positive ms to wait

In this case I would say that you should add this fix

@rozza
Copy link
Member

rozza commented Nov 28, 2017

@72MiguelGomes the issue with this fix is tryAcquire() does not respect other waiters on the permit - its greedy. Whereas tryAcquire(0, TimeUnit) does respect other waiters.

Having not heard back from @visualage and the belief that there is a fix in RxJava, I think this can be closed. However, please follow up if that is not the case.

@rozza rozza closed this Nov 28, 2017
@visualage
Copy link
Contributor Author

Sorry for the late reply. The rxjava fix would solve my problem, so this is not needed.

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