Skip to content

Commit

Permalink
fix: more non-interrupting future task cancellation cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Nov 22, 2023
1 parent 905e55b commit d883a75
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void request(long n) {
public void onCompletion() {
if (terminated.compareAndSet(RUNNING, SUCCEED)) {
if (task != null) {
task.cancel(true);
task.cancel(false);
task = null;
}
checkedComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void onCompletion() {
@Override
public void cancel() {
if (scheduledFuture != null) {
scheduledFuture.cancel(true);
scheduledFuture.cancel(false);
}
super.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ boolean replace(Future<?> task) {
Future current = container.get();
if (current == NONE) {
if (task != null) {
task.cancel(true);
task.cancel(false);

Check warning on line 270 in implementation/src/main/java/io/smallrye/mutiny/operators/multi/MultiWindowOnDurationOp.java

View check run for this annotation

Codecov / codecov/patch

implementation/src/main/java/io/smallrye/mutiny/operators/multi/MultiWindowOnDurationOp.java#L270

Added line #L270 was not covered by tests
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void cancel(ConnectableMultiConnection connection) {
}

ScheduledFuture<?> future = executor.schedule(connection, duration.toMillis(), TimeUnit.MILLISECONDS);
connection.setTimer(() -> future.cancel(true));
connection.setTimer(() -> future.cancel(false));
}

void terminated(ConnectableMultiConnection connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testAsUniWithNever() {
.onItem().ignoreAsUni().subscribeAsCompletionStage();

assertThat(future).isNotCompleted();
future.cancel(true);
future.cancel(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void testWithInterruptedFuture() {
UniAssertSubscriber<String> subscriber = UniAssertSubscriber.create();
CompletableFuture<String> cs = new CompletableFuture<>();
Uni.createFrom().future(cs).subscribe().withSubscriber(subscriber);
cs.cancel(true);
cs.cancel(false);
subscriber
.awaitFailure()
.assertFailedWith(CancellationException.class, null);
Expand Down

0 comments on commit d883a75

Please sign in to comment.