Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FailsafeExecutor.compose and .with(Executor) have surprising composition behavior #380

Open
stevenschlansker opened this issue Mar 27, 2024 · 0 comments

Comments

@stevenschlansker
Copy link
Contributor

Hi Failsafe fans,

We use a Failsafe retry executor to retry potentially failing network requests.
In response to an incident, we decide to .compose(CircuitBreaker)

Our original code:

failsafe = Failsafe.with(retryPolicy).with(asyncExecutor);

We updated the code:

failsafe = Failsafe.with(retryPolicy).with(asyncExecutor).compose(circuitBreakerPolicy);

However, this leads to surprising behavior - the .compose call creates a new executor but only copies the policies and not any other fields. This means your scheduler, executor, and any configured handlers are lost.

The correct version is:

failsafe = Failsafe.with(retryPolicy).compose(circuitBreakerPolicy).with(asyncExecutor)

I did not see any mention of this in the documentation. Should compose retain the other configurations on a FailsafeExecutor? Or, if that is not desirable, can we document .compose more specifically that it loses this configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant