Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class AlternatorLiveNodes extends Thread {
private final AtomicBoolean shutdownRequested = new AtomicBoolean(false);
private final SdkHttpClient pollingHttpClient;
private final boolean ownsPollingClient;
private final AtomicBoolean pollingClientClosed = new AtomicBoolean(false);
private final AtomicLong lastActivityTime = new AtomicLong(0);
private final LocalNodesResponseParser localNodesResponseParser;

Expand Down Expand Up @@ -94,7 +95,9 @@ public void run() {

/** Closes the polling HTTP client if this instance owns it. */
private void closePollingClient() {
if (ownsPollingClient && pollingHttpClient != null) {
if (ownsPollingClient
&& pollingHttpClient != null
&& pollingClientClosed.compareAndSet(false, true)) {
pollingHttpClient.close();
}
}
Expand All @@ -110,6 +113,7 @@ private void closePollingClient() {
public void shutdown() {
shutdownRequested.set(true);
this.interrupt();
closePollingClient();
}

/**
Expand Down