[ 
https://issues.apache.org/jira/browse/CAMEL-27774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Aurélien Pupier updated CAMEL-27774:
------------------------------------
    Component/s: camel-rxjava

> camel-reactor, camel-rxjava: to() request never completes when the exchange 
> completes before its completion callback is registered
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27774
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27774
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-reactor, camel-rxjava
>            Reporter: Aurélien Pupier
>            Assignee: Aurélien Pupier
>            Priority: Major
>             Fix For: 4.25.0
>
>
> The streams services of camel-reactor (ReactorStreamsService.doRequest) and 
> camel-rxjava (RxJavaStreamsService.doRequest) build the result of 
> CamelReactiveStreamsService.to(...) / toStream(...) as:
> {code}
> Mono.create(sink -> exchange.addOnCompletion(...)).doOnSubscribe(subs -> 
> consumer.process(data, ...))
> {code}
> (and the same with Single.create for RxJava).
> Reactor and RxJava both run the doOnSubscribe hook *before* the create 
> callback. The exchange is therefore handed to the thread pool of the 
> ReactiveStreamsConsumer before the Synchronization that signals its 
> completion is registered. When a pool thread completes the exchange first, 
> onComplete/onFailure is never seen, the Mono/Single never emits, and the 
> caller waits forever (or until its own timeout). The unsynchronized 
> onCompletions list of the exchange is also raced by the pool thread 
> (setUnitOfWork) and addOnCompletion.
> Fix: register the completion callback and then call consumer.process(...), 
> both inside the create callback.
> Found thanks to the flaky test ReactorStreamsServiceTest (testTo, 
> testToWithExchange, testToFunctionWithExchange failing with "Timeout on 
> blocking read for 30000000000 NANOSECONDS"), see CAMEL-26778. The same code 
> exists in 4.22.x and 4.18.x, so this is a backport candidate.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to