Files
spring-integration/spring-integration-core/src
Artem Bilan d2e1442905 GH-9866: Fix FluxMessageChannel for race condition on destroy
Fixes: #9866
Issue link: https://github.com/spring-projects/spring-integration/issues/9866

Due to race condition between `sink.tryEmitNext()` and `sink.emitComplete()``,
there could be a situation when `onNext` signal slips after `onComplete`.
Appears on fast producers into this `FluxMessageChannel`.
That leads to error like `Spec. Rule 1.3 - onSubscribe, onNext, onError and onComplete signaled to a Subscriber MUST be signaled serially.`

* Fix `FluxMessageChannel` to check for `this.active` one more time just before `sink.tryEmitNext()` call
* Also mitigate a race condition with a `Sinks.EmitFailureHandler.busyLooping(Duration.ofSeconds(1))` in the `destroy()`
instead of `Sinks.EmitFailureHandler.FAIL_FAST`.
The `busyLooping()` would retry requested `onComplete()` signal for that specific error until success or timeout

(cherry picked from commit 7680e02cbb)
2025-02-26 22:47:59 +00:00
..