@Test(expectedExceptions = ResourceNotFoundException.class) void testMaxRetriesExceededThrowsException() { int attempts = 5; BackoffOnNotFoundWhenGetBucketACL backoff = new BackoffOnNotFoundWhenGetBucketACL(mock); expect(mock.getBucketACL("foo")).andThrow(new ResourceNotFoundException()).times(attempts); replay(mock); backoff.load("foo"); }
@Override public AccessControlList load(String bucketName) { ResourceNotFoundException last = null; for (int currentTries = 0; currentTries < maxTries; currentTries++) { try { return client.getBucketACL(bucketName); } catch (ResourceNotFoundException e) { imposeBackoffExponentialDelay(100L, 200L, 2, currentTries, maxTries); last = e; } } throw last; }
BackoffOnNotFoundWhenGetBucketACL extends CacheLoader<String, AccessControlList> { @Override public AccessControlList load(String bucketName) { ResourceNotFoundException last = null; for (int currentTries = 0; currentTries < maxTries; currentTries++) { try { return client.getBucketACL(bucketName); } catch (ResourceNotFoundException e) { imposeBackoffExponentialDelay(100L, 200L, 2, currentTries, maxTries); last = e; } } throw last; } }
BackoffOnNotFoundWhenGetBucketACL extends CacheLoader<String, AccessControlList> { @Override public AccessControlList load(String bucketName) { ResourceNotFoundException last = null; for (int currentTries = 0; currentTries < maxTries; currentTries++) { try { return client.getBucketACL(bucketName); } catch (ResourceNotFoundException e) { imposeBackoffExponentialDelay(100L, 200L, 2, currentTries, maxTries); last = e; } } throw last; } @Inject  BackoffOnNotFoundWhenGetBucketACL(S3Client client); }
BackoffOnNotFoundWhenGetBucketACL extends CacheLoader<String, AccessControlList> { @Override public AccessControlList load(String bucketName) { ResourceNotFoundException last = null; for (int currentTries = 0; currentTries < maxTries; currentTries++) { try { return client.getBucketACL(bucketName); } catch (ResourceNotFoundException e) { imposeBackoffExponentialDelay(100L, 200L, 2, currentTries, maxTries); last = e; } } throw last; } @Inject  BackoffOnNotFoundWhenGetBucketACL(S3Client client); @Override AccessControlList load(String bucketName); @Override String toString(); }
BackoffOnNotFoundWhenGetBucketACL extends CacheLoader<String, AccessControlList> { @Override public AccessControlList load(String bucketName) { ResourceNotFoundException last = null; for (int currentTries = 0; currentTries < maxTries; currentTries++) { try { return client.getBucketACL(bucketName); } catch (ResourceNotFoundException e) { imposeBackoffExponentialDelay(100L, 200L, 2, currentTries, maxTries); last = e; } } throw last; } @Inject  BackoffOnNotFoundWhenGetBucketACL(S3Client client); @Override AccessControlList load(String bucketName); @Override String toString();  }