Skip to content

Commit e0b76b0

Browse files
committed
Moved the Assert.state(!completed) check out of ExecutionInternal.record(ExecutionResult)
1 parent c1f514f commit e0b76b0

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

src/main/java/net/jodah/failsafe/AsyncExecutionImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public void record(R result, Throwable failure) {
9393
// Guard against race with a timeout expiring
9494
synchronized (future) {
9595
if (!attemptRecorded) {
96+
Assert.state(!completed, "Execution has already been completed");
9697
record(new ExecutionResult<>(result, failure));
9798
}
9899

src/main/java/net/jodah/failsafe/ExecutionImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ public synchronized void recordAttempt() {
128128

129129
@Override
130130
public synchronized void record(ExecutionResult<R> result) {
131-
Assert.state(!completed, "Execution has already been completed");
132-
133131
if (preExecuted && !attemptRecorded) {
134132
recordAttempt();
135133
executions.incrementAndGet();
@@ -144,6 +142,7 @@ public synchronized void record(ExecutionResult<R> result) {
144142
* @throws IllegalStateException if the execution is already complete
145143
*/
146144
synchronized ExecutionResult<R> postExecute(ExecutionResult<R> result) {
145+
Assert.state(!completed, "Execution has already been completed");
147146
record(result);
148147
boolean allComplete = true;
149148
for (PolicyExecutor<R, ? extends Policy<R>> policyExecutor : policyExecutors) {

src/main/java/net/jodah/failsafe/spi/ExecutionInternal.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public interface ExecutionInternal<R> extends ExecutionContext<R> {
3333
/**
3434
* Records the {@code result} if the execution has been {@link #preExecute() pre-executed} and a result has not
3535
* already been recorded.
36-
*
37-
* @throws IllegalStateException if the execution is already complete
3836
*/
3937
void record(ExecutionResult<R> result);
4038

0 commit comments

Comments
 (0)