summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-06-07 13:54:45 +0200
committerGitHub <noreply@github.com>2021-06-07 13:54:45 +0200
commit3d606617bedce312541f4bb46b94d8e7867c9f87 (patch)
tree986577c60116ff0403efea5c7c0d7d129ec17ce0
parentd6fe9e5b14e2a5c1e46c7cb6fd287a9137e5b54b (diff)
parentb2be277ff37cffef10055eb141108b8a9847499e (diff)
Merge pull request #18151 from vespa-engine/jonmv/vespa-feed-client
Ensure dispatch thread is shut down
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
index 7a6e2120be6..a805c7eb195 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
@@ -63,12 +63,15 @@ class HttpRequestStrategy implements RequestStrategy {
this.maxInflight = builder.connectionsPerEndpoint * (long) builder.maxStreamsPerConnection;
this.minInflight = builder.connectionsPerEndpoint * (long) min(16, builder.maxStreamsPerConnection);
this.targetInflightX10 = new AtomicLong(10 * (long) (Math.sqrt(minInflight) * Math.sqrt(maxInflight)));
- new Thread(this::dispatch, "feed-client-dispatcher").start();
+
+ Thread dispatcher = new Thread(this::dispatch, "feed-client-dispatcher");
+ dispatcher.setDaemon(true);
+ dispatcher.start();
}
private void dispatch() {
try {
- while (breaker.state() != OPEN) {
+ while (breaker.state() != OPEN && ! destroyed.get()) {
while ( ! isInExcess() && poll() && breaker.state() == CLOSED);
// Sleep when circuit is half-open, nap when queue is empty, or we are throttled.
Thread.sleep(breaker.state() == HALF_OPEN ? 1000 : 10);