Skip to content

Commit

Permalink
Fix a race condition (Azure#41927)
Browse files Browse the repository at this point in the history
  • Loading branch information
heyams authored and mssfang committed Oct 21, 2024
1 parent 4957384 commit 31e43b4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ void scheduleWithFixedDelay(long interval) {
// Querying Azure Metadata Service is required for every 15 mins since VM id will get updated
// frequently.
// Starting and restarting a VM will generate a new VM id each time.
scheduledExecutor.scheduleWithFixedDelay(this, 60, interval, TimeUnit.SECONDS);
// Statsbeat can be shutdown before this call, so check if it is still running.
if (!scheduledExecutor.isShutdown() && !scheduledExecutor.isTerminated()) {
scheduledExecutor.scheduleWithFixedDelay(this, 60, interval, TimeUnit.SECONDS);
}
}

void shutdown() {
Expand Down

0 comments on commit 31e43b4

Please sign in to comment.