Class NeverRethrowMethodExceptionPolicy

java.lang.Object
com.societegenerale.failover.core.exception.policy.NeverRethrowMethodExceptionPolicy
All Implemented Interfaces:
MethodExceptionPolicy

public class NeverRethrowMethodExceptionPolicy extends Object implements MethodExceptionPolicy
MethodExceptionPolicy that never rethrows: it always returns the recovered result, suppressing the original exception in every case.

Decision logic:

  • If recoveredResult is non-null — return it; the caller is served stale data transparently and the failure is hidden.
  • If recoveredResult is null (store miss, expiry, or store failure) — return null (or the RecoveredPayloadHandler fallback) without rethrowing. The caller cannot tell an outage occurred from the return value alone.

This is the most lenient policy: callers are never interrupted, at the cost of masking upstream outages from the caller. Because the failure is invisible to the caller, the outage must be observed through metrics — the recover event still fires regardless of policy, so failover.recovery.outcome.total (outcome not_recovered) and failover.user.impact.total (impact blocked) remain the signal to alert on.

Contrast RethrowIfNoRecoveryMethodExceptionPolicy, the default, which rethrows when there is nothing to recover so the outage surfaces to the caller.

Author:
Anand Manissery
See Also:
  • Constructor Details

    • NeverRethrowMethodExceptionPolicy

      public NeverRethrowMethodExceptionPolicy()
  • Method Details

    • handle

      public <T> T handle(MethodExceptionContext<T> context)
      Description copied from interface: MethodExceptionPolicy
      Handles the exception context and returns the value to return to the caller, or throws to propagate the failure.
      Specified by:
      handle in interface MethodExceptionPolicy
      Type Parameters:
      T - the return type of the intercepted method
      Parameters:
      context - all available information about the failure and recovery attempt
      Returns:
      the value to return to the caller; may be null