[JAVA-3791] onNext errors should not throw if the subscription has been cancelled. Created: 17/Jul/20 Updated: 12/Apr/21 Resolved: 19/Nov/20 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Reactive Streams |
| Affects Version/s: | 4.0.3, 4.0.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Yue Gu | Assignee: | Ross Lawley |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Below is a short description of my trouble, if it make any annoyance, I could write some code to repeat the problem. When a MongoConverter threw an fatal exception(`reactor.core#Exceptions.throwIfFatal`), `com.mongodb.reactivestreams.client.internal#AbstractSubscription.onNext` catched the throwable, and check if subscriber is terminated to invoke the `onError` method, but the subscriber was canceled at `reactor.core.publisher#onNext`, as a result, nothing was passed to userland code. I'm not sure it's the bug of reactive mongodb project or reactor project, but I believe it's not user's expecting. Please check it and at least tell me how resolve this. |
| Comments |
| Comment by Yue Gu [ 12/Apr/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I retried to execute above case, updated dependencies to:
Looks like nothing was fixed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 19/Nov/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The work in | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 05/Aug/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks h1023263204@gmail.com, I was able to reproduce the issue and can see that we can improve and ensure onNext doesnt throw an exception. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 05/Aug/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think the issue here is MonoNext has the following sequence of events:
Calling onNext causes a failure but due to the subscription being cancelled onError throws rather than calling the subscribers onError. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 27/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the repo - will review. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yue Gu [ 24/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This is a sample of my question. Application will hang up and my doOnError callback cannot be invoked. If you use maven:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 22/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You seem to be using a layer above the reactive streams driver, all I can comment on is the reactive streams driver appears to be working as design and as to specification. Without a general reproduction case of the error, I can't see where the fault is or where the bug actually is. Ross
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yue Gu [ 22/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for your reply. Actually, there is a signal sent by publisher but which was not sent to it's subscriber and onError wasn't called because of something wrong. When the MappingMongoConverter threw an InstantiationError while converting mongodb document to java object, the error will be logged but the subscriber can not get any signal. If this behavior works as designed, please tell me how to do to receive the error signal when error happened.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 21/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For the reasons stated above, I'm closing this ticket as "works as designed"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 21/Jul/20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I believe this is behaviour correct to specification:
I think you may need to look at the logic in your application.
So for signalling errors the only way to signal an error should be via onError. I hope that helps, Ross |