0

I'm trying to update net.jodah.failsafe from 1.0.4 to 2.4.4. I have code that uses SyncFailSafe and BiPredicate classes, which don't seem to be available anymore in 2.4.4. What would be the replacement for that? Many times there is a direct replacement when updating libraries, but I can't seem to find anything online. I appreciate your help!

Edit. Thanks Matt. java.util's BiPredicate seems to be the replacement for that one.

For SyncFailsafe, usage is very simple. example code:

public <T> SyncFailsafe<T> create() {
    RetryPolicy retryPolicy = ... // some code to create it.
    return Failsafe.with(retryPolicy);
}

in the code:
create().run(() -> {
   // makes a REST request and and sets a value to the GetCallResponse object
}

this used to return SyncFailsafe. I'm seeing it is now returning FailsafeExecutor, but I'm not sure if it's the same thing...

6
  • Java has a built in BiPredicate class now. Does that do what you want. Maybe you can include an example of how you're using SyncFailSafe. Also, I added the java-failsafe tag. It seems like that is the library you're using.
    – matt
    Commented Aug 30 at 7:13
  • as for the tags, not sure if java-failsafe is the right one. the lib is net.jodah.failsafe:1.0.4 -> 2.4.4 (i cant add new tags)
    – Hani
    Commented Aug 30 at 8:04
  • The tag has an associated webpage Project documentation jodah.net/failsafe plus the description sounds the same. I think your example is missing something. What do you do with the SyncFailsafe object that gets returned. It seems like the executor has the appropriate methods, but it add async versions too.
    – matt
    Commented Aug 30 at 8:08
  • got it. edited. so it already does create an async run...
    – Hani
    Commented Aug 30 at 23:35
  • It appears that FailsafeExecutor.run is the SyncFailsafe.run, if you want it async then you would use runAsync.
    – matt
    Commented Aug 31 at 13:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.