failsafe
failsafe copied to clipboard
Add a typed parameter for the failure in FailurePolicy.handleIf
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
After code is missing method name, should be:
policy.<HttpException>handleIf((result, failure) -> failure.isServerError());
🤦 thanks, edited.