- Fixed #224 - Allow combining random delay and jitter.
- Added
CircuitBreaker.getRemainingDelay()
. - Added support for
Fallback.VOID
.
- Fixed #216 - Incorrect computation of randomDelay.
- Set
setRemoveOnCancelPolicy(true)
for the internal delay scheduler. - Added
Scheduler.DEFAULT
to return the default scheduler Failsafe uses.
- Fixed #206 - Problem with Fallback converting from failure to success.
FailsafeExecutor.get
andFailsafeExecutor.run
will no longer wrapError
instances inFailsafeException
before throwing.
- Fixed potential race between
Timeout
interrupts and execution completion.
- Added a new
Timeout
policy that fails withTimeoutExceededException
. - Added
ExecutionContext.isCancelled()
. - Added
ExecutionContext.getElapsedAttemptTime()
. - Made the internal delay scheduler more adaptive.
- Deprecated
CircuitBreaker.withTimeout
in favor of using a separateTimeout
policy.
- Reset interrupt flag when a synchronous execution is interrupted.
- Improved handling around externally completing a Failsafe
CompletableFuture
.
- Added support for
CircuitBreaker.withDelay(DelayFunction)
- Added
Fallback.ofException
for returning custom exceptions. - Added
ExecutionContext.getLastResult
and.getLastFailure
to support retries that depend on previous executions - Added
CircuitBreakerOpenException.getCircuitBreaker
RetryPolicy.DelayedFunction
was moved to thenet.jodah.failsafe.function
package.- Removed
RetryPolicy.canApplyDelayFn
- Added support for
Failsafe.with(List<Policy<R>>)
. - Allow
null
Fallback
values.
- A standalone or async execution will only be marked as complete when all policies are complete.
Execution.isComplete
reflects this.
- Issue #190 - Failure listener called on success for async executions.
- Issue #191 - Add missing listeners to RetryPolicy copy constructor.
- Issue #192 - Problem with detecting completion when performing async execution.
- Added support for using
ExecutorService
viaFailsafeExecutor.with(ExecutorService)
. - Added interruptable cancellation for executions ran on
ForkJoinPool
viaCompletableFuture.cancel(true)
.
- Issue #171 - Handle completed futures when using
getStageAsync
.
- Policy composition is now supported.
- A Policy SPI is now available.
- Async execution is now supported without requiring that a
ScheduledExecutorService
orScheduler
be configured. When no scheduler is configured, theForkJoinPool
's common pool will be used by default. Fallback
now support async execution viaofAsync
.CircuitBreaker
supports execution metrics (see below).- Strong typing based on result types is supported throughout the API.
RetryPolicy
now has 3 max attempts by default.CircuitBreaker
now has a 1 minute delay by default.
- Java 8+ is now required
Failsafe 2.0 includes a few API changes from 1.x that were meant to consolidate behavior such as the execution APIs, which are now based on common Policy
implementations, while adding some new features such as Policy
composition.
- Policies
- Policy implementations now take a type parameter
R
that represents the expected result type. - Some of the time related policy configurations have been changed to use
Duration
instead oflong
+TimeUnit
.
- Policy implementations now take a type parameter
- Policy configuration
- Multiple policies can no longer be configured by chaining multiple
Failsafe.with
calls. Instead they must be supplied in a singleFailsafe.with
call. This is was intentional to require users to consider the ordering of composed policies. See the README section on policy composition for more details.
- Multiple policies can no longer be configured by chaining multiple
- RetryPoilicy
- The
retryOn
,retryIf
, andretryWhen
methods have been replace withhandleOn
, etc.
- The
- CircuitBreaker
- The
failOn
,failIf
, andfailWhen
methods have been replace withhandleOn
, etc.
- The
- Fallbacks
- Fallbacks must be wrapped in a
Fallback
instance viaFallback.of
- Fallbacks must be wrapped in a
- Failsafe APIs
Supplier
s are now used instead ofCallable
s.withFallback
is no longer supported. Instead,Failsafe.with(fallback...)
should be used.
- Async execution
- Async execution is now performed with the
getAsync
,runAsync
,getStageAsync
, etc. methods. - Async API integration is now supported via the
getAsyncExecution
,runAsyncExecution
, etc. methods.
- Async execution is now performed with the
- Event listeners
- Event listeners now all consume a single
ExecutionEvent
object, which includes references to the result, failure, and other information. - Event listeners that are specific to policies, such as
onRetry
forRetryPolicy
, must now be configured through the policy instance. The top levelFailsafe
API only supportsonComplete
,onSuccess
, andonFailure
. IndividualPolicy
implementations still supportonSuccess
andonFailure
in addition to policy specific events. - The top level
Failsafe.onSuccess
event listener will only be called if all configured policies consider an execution to be successful, otherwiseonFailure
will be called. - The
Listeners
class was removed, since it was mostly intended for Java 6/7 users. - The async event listener APIs were removed. Events will always be delivered in the same thread as the execution that they follow or preceed, including for async executions.
- Event listeners now all consume a single
- Java 8
java.time.Duration
is used instead of Failsafe's ownDuration
impl.ChronoUnit
is used instead ofTimeUnit
in policies.
ExecutionContext.getExecutions
is nowgetAttemptCount
.Schedulers.of(ScheduledExecutorService)
was moved to theScheduler
interface.
CircuitBreaker
preExecute
is now exposed to support standalone usage.- Execution metrics are available via
getFailureCount
,getFailureRatio
,getSuccessCount
, andgetSuccessRatio
.
- Issue #152 - Min/max delay was not being computed correctly
- Issue #115 - Jitter bigger than Delay causes a (random) failure at runtime
- Issue #116 - Setting jitter without a delay works fine bug
- Issue #123 - Ability to reset the jitterFactor
- Issue #110 - Added support for computed delays:
RetryPolicy.withDelay(DelayFunction)
- Issue #126 - Added support for random delays:
RetryPolicy.withDelay(1, 10, TimeUnit.MILLISECONDS)
- Issue #97 - Should not increment exponential backoff time on first attempt
- Issue #92 -
handleRetriesExceeded
called incorrectly.
- Asynchronous execution attempts no longer throw
CircuitBreakerOpenException
if a configuredCircuitBreaker
is open when an execution is first attempted. Instead, the resultingFuture
is completed exceptionally withCircuitBreakerOpenException
. See issue #84.
- Issue #81 - Added single argument failure configuration to avoid varargs related warnings.
- Fixed #76 - Make sure AsyncExecution.completeOrRetry is called when Error is thrown.
- Fixed #75 - Incorrect future completion when a fallback is present.
FailsafeException
now has public constructors, for easier mocking and testing.
- Failsafe will now only throw
FailsafeException
when an execution fails with a checkedException
. See issue #66 for details.
- Fixed #59 - Classloading issue on Java 6/7.
- Fixed #63 - Proper handling of thread interrupts during synchronous execution delays.
- Fixed #54 - Added hashCode and equals implementations to Duration.
- Added OSGi support.
FailsafeFutuer.cancel
calls completion handlers..get
after cancel throwsCancellationException
.
- Fixed #52 - FailsafeFuture.cancel not working as expected.
- Fixed #55 - Fallback always called for asynchronous executions.
CircuitBreakerOpenException
now extendsFailsafeException
.
- Various fallback and listener API additions and improvements
- Added support for retry delay jitter.
- Added support for fallbacks.
- Fixed issue #36 - Failed attempt listener not always called on completion.
- Fixed issue #34 - CircuitBreaker should default to closed state.
- Fixed #33 -
CircuitBreaker
not decrementing currentExections when under load
- Added support for
onRetriesExceeded
listeners. RetryPolicy
can be extended (it's no longer marked as final)
- Abort should not call failure listeners.
- Simplified listeners API.
- Added support for failure listeners via
Failsafe.with(...).onFailure(e -> {})
. - Added
onAbort
listeners. - Added additional async listeners.
RetryPolicy
andCircuitBreaker
now support multiple configuration rules. Ex:new RetryPolicy().retryWhen(null).retryWhen("")
. If any rule matches then the policy is matched.
- Added top level support for listener registration via
Failsafe.with(...).onXxx
. TheListeners
class is now only meant for Java 6 and 7 usage via method overrides. - Removed listener registration from
Listeners
class. - Removed
AsyncListeners
class. - Removed listener registration from
FailsafeFuture
class.
- Added support for circuit breakers
- Project renamed from Recurrent to Failsafe
- Added better support for scheduling failure handling
- Fixed RetryPolicy failure assignability checking
- Invocation APIs were renamed to Execution to better align with the
java.util.concurrent
naming. InvocationStats.getAttemptCount()
was renamed toExecutionStats.getExecutions()
- Added additional contextual callable and runnable support
- Changed to a new API entry point:
Recurrent.with
. - Added
.with
for configuring listeners.
- Added
RetryPolicy.abortOn
,abortWhen
andabortIf
methods to abort retries when matched.
RetryPolicy.retryWhen
was renamed toretryIf
for retrying if aPredicate
is matched.RetryPolicy.retryFor
was renamed toretryWhen
for retrying when a result is matched.Scheduler
andSchedulers
were moved tonet.jodah.recurrent.util.concurrent
.
- Added support for synchronous and asynchronous event listeners
- Added support for
CheckedRunnable
- The
Recurrent.run
methods now require aCheckedRunnable
rather thanRunnable
. This allows Recurrent to be used on code that throws checked exceptions without having to wrap the code in try/catch blocks. - The synchronous
Recurrent.run
andRecurrent.get
methods will throw aRecurrentException
if a failure occurs and the retry policy is exceeded.
- Added better support for invocation tracking
- New Invocation and
AsyncInvocation
APIs
- Add
Scheduler
API - Make
RetryPolicy
copyable
- Require
ContextualCallable
andContextualRunnable
to be manually retried - Add support for checking multiple retry policy conditions
- Make ContextualRunnable throw Exception
- Add support for retrying when an invocation result matches a policy
- Added support for seprate retry tracking.
- Initial Release