Skip to content

Commit

Permalink
Do not check the return value of Future.cancel()
Browse files Browse the repository at this point in the history
Future.cancel() is expected to return false if the future is done or had been cancelled
previously, and there doesn't seem to be a way to check whether or not that is the case
without a race condition.

RELNOTES: None.
PiperOrigin-RevId: 339686101
  • Loading branch information
tetromino authored and copybara-github committed Oct 29, 2020
1 parent 388e029 commit ad18145
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ private static void stopBranch(
// reference to its own identifier wins and is allowed to issue the cancellation; the other
// branch just has to give up execution.
if (strategyThatCancelled.compareAndSet(null, cancellingStrategy)) {
boolean cancelled = branch.cancel(true);
checkState(cancelled, "Failed to cancel other branch from %s", cancellingStrategy);
branch.cancel(true);
branchDone.acquire();
} else {
throw new DynamicInterruptedException(
Expand Down

0 comments on commit ad18145

Please sign in to comment.