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

Add a typed parameter for the failure in FailurePolicy.handleIf #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhalterman
Copy link
Member

@jhalterman jhalterman commented Aug 13, 2021

Small improvement, though I'm not sure if it's worth doing. Thoughts?

--

This is meant to make it slightly (maybe? arguably?) easier to write FailurePolicy.handleIf statements that are specifically typed. Ex:

Before

policy.handleIf((Object result, HttpException failure) -> failure.isServerError())

After

policy.<HttpException>handleIf((result, failure) -> failure.isServerError());

This could open the door for ClassCastExceptions, but those are ignored by FailurePoilicy: https://github.com/failsafe-lib/failsafe/blob/master/src/main/java/net/jodah/failsafe/FailurePolicy.java#L160-L162

@Tembrel
Copy link
Contributor

Tembrel commented Aug 13, 2021

After code is missing method name, should be:

policy.<HttpException>handleIf((result, failure) -> failure.isServerError());

@jhalterman
Copy link
Member Author

🤦 thanks, edited.

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

Successfully merging this pull request may close these issues.

2 participants