[JAVA-4524] Observable.map calls onComplete after onError Created: 09/Mar/22 Updated: 04/May/22 Resolved: 16/Mar/22 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Scala |
| Affects Version/s: | 4.5.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Ostrzyciel Nożyczek | Assignee: | Ross Lawley |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
SummaryDriver version: 4.5.0 Following up from JAVA-4304, it seems that Observable.map does not take into account whether the inner function threw an exception when calling onComplete. So, when an exception occurs, MapObservable first calls onError (which is fine) and then onComplete on the the next Observer in the chain, which is against the reactive streams spec. How to ReproduceThe following code will throw an IllegalStateException in ToSingleObservablePublisher with message "onComplete called after the Observer has already completed or errored." val future = SingleObservable[Int](1).map( { x => Additional BackgroundI've managed to circumvent the bug by making a patched version of the Observable.map method that simply does not call onComplete after an exception has occured in the inner function. My code is really bad and Scala 3, though, so sharing it won't help much. |
| Comments |
| Comment by Ostrzyciel Nożyczek [ 16/Mar/22 ] |
|
Thanks for investigating this! |
| Comment by Ross Lawley [ 16/Mar/22 ] |
|
Hi ostrzycielnozyczek@gmail.com, After testing, I can confirm this was fixed by Ross |
| Comment by Ross Lawley [ 15/Mar/22 ] |
|
Hi ostrzycielnozyczek@gmail.com, According to the reactive streams spec 2.13, throwing an error from onNext is not allowed.
However, I will add a further check to ensure onComplete isn't called - as that is definitely a bug in the mapping observable and I'll ensure that the error is propagated correctly. Ross |
| Comment by Esha Bhargava [ 11/Mar/22 ] |
|
ostrzycielnozyczek@gmail.com Thank you for reporting this issue! We'll look into it and get back to you soon. |