aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-06-07 13:36:55 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-06-07 13:36:55 +0200
commitb2be277ff37cffef10055eb141108b8a9847499e (patch)
tree1501af392f870a370d2713efbb93306ede77742f /vespa-feed-client
parentf62c3b5492ed540b75e046f426499066e1bd7ca6 (diff)
Ensure dispatch thread is shut down
Diffstat (limited to 'vespa-feed-client')
-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);