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 serves recovered data when available, and cascades the original exception only when there is nothing to recover.

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) — rethrow the original exception so the caller can react to the outage explicitly.

This is the "best-effort" policy: prefer stale data, but be honest when even that is unavailable.

Author:
Anand Manissery
  • 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