I'm implementing a retry policy. Basically what I want to do is retry a POST request on a separate thread. I'm using Failsafe (https://failsafe.dev/async-execution/#async-integration) Here is my code
Failsafe.with(retryPolicy).with(executor).future(() -> CompletableFuture.supplyAsync(() -> {
try {
CloseableHttpResponse response = client.execute(httpPost);
httpPost.releaseConnection();
client.close();
return response;
} catch (IOException e) {
return null;
}
}).thenApplyAsync(response -> "Response: " + response)
.thenAccept(System.out::println));
I don't want to catch the IOException here. It is handled by the retry policy. Currently retrying won't happen since I'm catching the exception here. Is there a way to throw an exception from 'supplyAsync' so it will be handled by the retry policy? Thanks. Thanks