I wonder how I can do something with Failsafe.
If methods which do a retry with Failsafe are nested then how can I prevent in the outter method that a retry is performed when an exception is thrown after the last retry of a inner method?
I would like to use the same Exception type in both aaa() and in ddd(), AssertionError.class.
public static void aaa() {
Failsafe.with(RetryPolicy.builder()
.withMaxRetries(1)
.handle(AssertionError.class)
.build())
.run(() -> {
System.out.println("aaa");
bbb();
});
}
public static void bbb() {
System.out.println("bbb");
ccc();
ddd();
}
public static void ccc() {
System.out.println("ccc");
}
public static void ddd() {
Failsafe.with(RetryPolicy.builder()
.withMaxRetries(1)
.handle(AssertionError.class)
.build())
.run(() -> {
System.out.println("ddd");
throw new AssertionError("ddd");
});
}
public static void main(String[] args) {
MyClass.aaa();
MyClass.bbb();
}
The console output should be:
But it is:
- aaa
- bbb
- ccc
- ddd
- ddd
- aaa
- bbb
- ccc
- ddd
- ddd
I guess it could be done if there would be something like a marker or so, to flag the exception thrown by a inner retry method so that it if the flag is present it does not do a retry in the outter method, even if the exception types match.
I wonder how I can do something with Failsafe.
If methods which do a retry with Failsafe are nested then how can I prevent in the outter method that a retry is performed when an exception is thrown after the last retry of a inner method?
I would like to use the same Exception type in both
aaa()and inddd(),AssertionError.class.The console output should be:
But it is:
I guess it could be done if there would be something like a marker or so, to flag the exception thrown by a inner retry method so that it if the flag is present it does not do a retry in the outter method, even if the exception types match.