Class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>

  • All Implemented Interfaces:
    com.google.common.base.Supplier<T>, Supplier<T>

    public class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
    extends com.google.common.collect.ForwardingObject
    implements com.google.common.base.Supplier<T>
    This will retry the supplier if it encounters a timeout exception, but not if it encounters an AuthorizationException.

    A shared exception reference is used so that anyone who encounters an authorizationexception will be short-circuited. This prevents accounts from being locked out.

    details

    http://code.google.com/p/google-guice/issues/detail?id=483 guice doesn't remember when singleton providers throw exceptions. in this case, if the supplier fails with an authorization exception, it is called again for each provider method that depends on it. To short-circuit this, we remember the last exception trusting that guice is single-threaded. Note this implementation is folded into the same class, vs being decorated as stacktraces are exceptionally long and difficult to grok otherwise. We use LoadingCache to deal with concurrency issues related to the supplier.