use of org.springframework.retry.ExhaustedRetryException in project spring-retry by spring-projects.
the class CircuitBreakerStatisticsTests method testFailedRecoveryCountsAsAbort.
@Test
public void testFailedRecoveryCountsAsAbort() throws Throwable {
this.retryTemplate.setRetryPolicy(new CircuitBreakerRetryPolicy(new NeverRetryPolicy()));
this.recovery = new RecoveryCallback<Object>() {
@Override
public Object recover(RetryContext context) throws Exception {
throw new ExhaustedRetryException("Planned exhausted");
}
};
try {
this.retryTemplate.execute(this.callback, this.recovery, this.state);
fail("Expected ExhaustedRetryException");
} catch (ExhaustedRetryException e) {
// Fine
}
MutableRetryStatistics stats = (MutableRetryStatistics) repository.findOne("test");
assertEquals(1, stats.getStartedCount());
assertEquals(1, stats.getAbortCount());
assertEquals(0, stats.getRecoveryCount());
}
use of org.springframework.retry.ExhaustedRetryException in project spring-batch by spring-projects.
the class FaultTolerantStepBuilder method getRollbackClassifier.
/**
* Convenience method to get an exception classifier based on the provided transaction attributes.
*
* @return an exception classifier: maps to true if an exception should cause rollback
*/
protected Classifier<Throwable, Boolean> getRollbackClassifier() {
Classifier<Throwable, Boolean> classifier = new BinaryExceptionClassifier(noRollbackExceptionClasses, false);
// (should be pretty uncommon):
if (!classifier.classify(new ForceRollbackForWriteSkipException("test", new RuntimeException())) || !classifier.classify(new ExhaustedRetryException("test"))) {
final Classifier<Throwable, Boolean> binary = classifier;
Collection<Class<? extends Throwable>> types = new HashSet<>();
types.add(ForceRollbackForWriteSkipException.class);
types.add(ExhaustedRetryException.class);
final Classifier<Throwable, Boolean> panic = new BinaryExceptionClassifier(types, true);
classifier = (Classifier<Throwable, Boolean>) classifiable -> {
return panic.classify(classifiable) || binary.classify(classifiable);
};
}
return classifier;
}
use of org.springframework.retry.ExhaustedRetryException in project cwa-server by corona-warn-app.
the class RemoteStatisticJsonFileLoaderTest method shouldUnauthorizedFileException.
@Test
void shouldUnauthorizedFileException() {
var mockException = mock(S3Exception.class);
when(mockS3client.getSingleObjectContent(anyString(), anyString())).thenThrow(new ExhaustedRetryException("", mockException));
var loader = new RemoteStatisticJsonFileLoader(mockS3client, serviceConfig);
assertThrows(FilePathNotFoundException.class, loader::getFile);
}
use of org.springframework.retry.ExhaustedRetryException in project cwa-server by corona-warn-app.
the class RemoteStatisticJsonFileLoaderTest method shouldThrowBucketNotFound.
@Test
void shouldThrowBucketNotFound() {
var mockException = mock(NoSuchBucketException.class);
when(mockS3client.getSingleObjectContent(anyString(), anyString())).thenThrow(new ExhaustedRetryException("", mockException));
var loader = new RemoteStatisticJsonFileLoader(mockS3client, serviceConfig);
assertThrows(BucketNotFoundException.class, loader::getFile);
}
use of org.springframework.retry.ExhaustedRetryException in project cwa-server by corona-warn-app.
the class RemoteStatisticJsonFileLoaderTest method shouldThrowConnectionException.
@Test
void shouldThrowConnectionException() {
var mockException = mock(SdkClientException.class);
when(mockS3client.getSingleObjectContent(anyString(), anyString())).thenThrow(new ExhaustedRetryException("", mockException));
var loader = new RemoteStatisticJsonFileLoader(mockS3client, serviceConfig);
assertThrows(ConnectionException.class, loader::getFile);
}
Aggregations