-
Notifications
You must be signed in to change notification settings - Fork 105
fix: Watchdog does not does not wait for executor to shutdown on awaitTermination #1884
Conversation
…ng if the executor is provided by ExecutorProvider.
Kudos, SonarCloud Quality Gate passed! |
} | ||
|
||
@Override | ||
public void shutdownNow() { | ||
future.cancel(true); | ||
// Unregister the main thread | ||
phaser.arriveAndDeregister(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to avoid double calls:
if (future.cancel(true)) {
phaser.arriveAndDeregister();
}
@@ -134,26 +143,37 @@ private void runUnsafe() { | |||
@Override | |||
public void shutdown() { | |||
future.cancel(false); | |||
// Unregister the main thread | |||
phaser.arriveAndDeregister(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to avoid double calls:
if (future.cancel(true)) {
phaser.arriveAndDeregister();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm after comment
@igorbernstein2 I don't think this PR is still relevant because we went with: #1890. But we can wait for @blakeli0 to confirm. Update: I see it was planned as a further improvement to #1890. So never mind. |
Closing this in favor of googleapis/sdk-platform-java#1337 |
fixes: #1858
Watchdog does not wait for executor to shutdown on awaitTermination. Instead, use
Phaser
to track the lifecycle of eachrun()
execution, wait for thePhaser
to proceed to next phase(which is terminated phase in our case) inawaitTermination
and usephaser.isTerminated()
to determine if Watchdog is terminated or not.