Skip to content

Commit ff160d4

Browse files
committed
PolicyExecutor should not preExecute on applyAsync when execution is already recorded
1 parent 93c3335 commit ff160d4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/dev/failsafe/spi/PolicyExecutor.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ public Function<AsyncExecutionInternal<R>, CompletableFuture<ExecutionResult<R>>
105105
FailsafeFuture<R> future) {
106106

107107
return execution -> {
108-
ExecutionResult<R> result = preExecute();
109-
if (result != null) {
110-
// Still need to preExecute when returning an alternative result before making it to the terminal Supplier
111-
execution.preExecute();
112-
return CompletableFuture.completedFuture(result);
108+
if (!execution.isRecorded()) {
109+
ExecutionResult<R> result = preExecute();
110+
if (result != null) {
111+
// Still need to preExecute when returning an alternative result before making it to the terminal Supplier
112+
execution.preExecute();
113+
return CompletableFuture.completedFuture(result);
114+
}
113115
}
114116

115117
return innerFn.apply(execution).thenCompose(r -> {

0 commit comments

Comments
 (0)