SlidingWindowRetryPolicy { public boolean shouldRetry(RetryContext retryContext, int errorCode) { ContainerRetryContext containerRC = retryContext.containerRetryContext; Preconditions.checkNotNull(containerRC, "container retry context null"); ContainerRetryPolicy retryPolicy = containerRC.getRetryPolicy(); if (retryPolicy == ContainerRetryPolicy.RETRY_ON_ALL_ERRORS || (retryPolicy == ContainerRetryPolicy.RETRY_ON_SPECIFIC_ERROR_CODES && containerRC.getErrorCodes() != null && containerRC.getErrorCodes().contains(errorCode))) { return containerRC.getMaxRetries() == ContainerRetryContext.RETRY_FOREVER || calculateRemainingRetries(retryContext) > 0; } return false; } SlidingWindowRetryPolicy(Clock clock); boolean shouldRetry(RetryContext retryContext,
      int errorCode); void setClock(Clock clock);  }
@Test public void testNeverRetry() { ContainerRetryContext retryContext = ContainerRetryContext.NEVER_RETRY_CONTEXT; Assert.assertFalse("never retry", retryPolicy.shouldRetry( new SlidingWindowRetryPolicy.RetryContext(retryContext), 12)); }
@Test public void testAlwaysRetry() { ContainerRetryContext retryContext = ContainerRetryContext.newInstance( ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1, 0, 10); Assert.assertTrue("always retry", retryPolicy.shouldRetry( new SlidingWindowRetryPolicy.RetryContext(retryContext), 12)); }