Reactor Bulkhead operator blocks if max wait duration is set

Author: tsrokaCreated Dec 7, 2021Updated Aug 28, 2026
Labelsenhancement

Resilience4j version: 1.7.0

Java version: 17

MonoBulkhead and FluxBulkhead operators both use bulkhead.tryAcquirePermission() during the subscription. This is not ideal since bulkhead.tryAcquirePermission() calls semaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS) which blocks a thread on which subscription is being executed, as per javadoc of tryAcquire:

If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens

so ,for example, it might block IO thread which is used to serve other requests.

Both of those operators should never block and instead:

  • accept / reject immediately - as it happens currently without timeout set, but if it is not possible and there is a timeout set then it should:
  • queue the subscription for later so that when permit is released it is being granted to first waiting subscription (although I am not sure if the current semaphore based bulkhead implementation is a good solution to base it on)

Seems like rxjava2 and rxjava3 versions are also blocking.

Source: resilience4j/resilience4j