Retry a method based on result (instead of exception)
问题 I have a method with the following signature: public Optional<String> doSomething() { ... } If I get an empty Optional I'd like to retry this method and only after 3 times return the empty Optional . I've looked and found the Retryable spring annotation, but it seems to only work on Exceptions. If possible I'd like to use a library for this, and avoid: Creating and throwing an exception. Writing the logic myself. 回答1: I have been using failsafe build in retry. You can retry based on