Callables { static long overflowSafeAdd(final long currentTime, final long timeout) { if (currentTime < 0) { throw new IllegalArgumentException("Time must be positive, not " + currentTime); } if (timeout < 0) { return currentTime; } long result = currentTime + timeout; if ((currentTime ^ timeout) < 0 || (currentTime ^ result) >= 0) { return result; } else { return Long.MAX_VALUE; } } private  Callables(); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, EX> what,
          final int nrImmediateRetries,
          final int maxRetryWaitMillis, final Class<EX> exceptionClass); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, RuntimeException> what,
          final int nrImmediateRetries, final int maxRetryWaitMillis); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, EX> what,
          final int nrImmediateRetries,
          final int maxRetryWaitMillis,
          final AdvancedRetryPredicate<Exception> retryOnException,
          final Class<EX> exceptionClass); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, RuntimeException> what,
          final int nrImmediateRetries, final int maxRetryWaitMillis,
          final AdvancedRetryPredicate<Exception> retryOnException); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, EX> what,
          final int nrImmediateRetries, final int maxWaitMillis,
          final TimeoutRetryPredicate<? super T, T> retryOnReturnVal,
          final AdvancedRetryPredicate<Exception> retryOnException,
          final Class<EX> exceptionClass); @Deprecated static Class rootClass(final Exception f); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, EX> what,
          final TimeoutRetryPredicate<? super T, T> retryOnReturnVal,
          final TimeoutRetryPredicate<Exception, T> retryOnException, final Class<EX> exceptionClass); @Deprecated @Nullable static T executeWithRetry(final TimeoutCallable<T, EX> what,
          final TimeoutRetryPredicate<Exception, T> retryOnException, final Class<EX> exceptionClass); @Deprecated @SuppressFBWarnings({ "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", "MDM_THREAD_YIELD" }) @Nullable static T executeWithRetry(
          final CheckedCallable<T, EX> pwhat,
          final RetryPredicate<? super T, T> retryOnReturnVal,
          final RetryPredicate<Exception, T> retryOnException,
          final Class<EX> exceptionClass); static Callable<T> synchronize(final Callable<T> callable); static Callable<T> withName(final Callable<T> callable, final String name); static MemorizedCallable<V> memorized(final Callable<V> source); static Callable<V> constant(final V value); static Callable<Void> from(final Runnable value); @Deprecated
  static final SimpleRetryPredicate<?> RETRY_FOR_NULL_RESULT; @Deprecated
  static final AdvancedRetryPredicate<Exception> DEFAULT_EXCEPTION_RETRY; @Deprecated
  static final Predicate<Exception> DEFAULT_EXCEPTION_RETRY_PREDICATE; }
@Test public void testOverflow() { Assert.assertEquals(Long.MAX_VALUE, Callables.overflowSafeAdd(Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, Callables.overflowSafeAdd(Long.MAX_VALUE, Long.MAX_VALUE)); Assert.assertEquals(3, Callables.overflowSafeAdd(1, 2)); }