Completing the result of a RowPublisherOperation
douglas.surber at oracle.com
Thu Jul 19 15:02:35 UTC 2018
I presented ADBA at the Silicon Valley Java Users Group last night. A person there asked an excellent question.
A RowPublisherOperation has a Subscriber and a CompletionStage that provides the result of the Operation. What happens if the CompletionStage is completed before onError or onComplete is called? That is the Subscriber is busily processing RowColumns and for whatever reason calls CompletableFuture.complete(foo) on the result while still continuing to process RowColumns.
The interesting part of this question is that completing the result allows the next Operation to execute while at the same time the Subscriber continues to process rows.
Here are some alternatives:
- Disallow it. Require that onError or onComplete must be called before the result is completed.
- Do What I Mean. Completing the result before onError or onComplete is the same as calling cancel.
- Ignore it. The Operation completes only when the result is completed and onError or onComplete return.
- Run with it. The Operation completes when the result is completed and the implementation continues to call onNext.
- Vendor specific. The implementation continues to call onNext. The Operation completes when the implementation decides to complete it. Maybe immediately. Maybe after all the rows are processed. Maybe somewhere in between. Somewhere between Ignore it and Run with it inclusive.
More information about the jdbc-spec-discuss