failsafe icon indicating copy to clipboard operation
failsafe copied to clipboard

Add a typed parameter for the failure in FailurePolicy.handleIf

Open jhalterman opened this issue 3 years ago • 2 comments

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

jhalterman avatar Aug 13 '21 04:08 jhalterman

After code is missing method name, should be:

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

Tembrel avatar Aug 13 '21 12:08 Tembrel

🤦 thanks, edited.

jhalterman avatar Aug 13 '21 14:08 jhalterman