Skip to content

Commit 0b5cf2d

Browse files
committed
[grid] shutdown executors created for a single tasks
1 parent c34fc94 commit 0b5cf2d

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.Set;
4646
import java.util.concurrent.ConcurrentHashMap;
4747
import java.util.concurrent.Executor;
48+
import java.util.concurrent.ExecutorService;
4849
import java.util.concurrent.Executors;
4950
import java.util.concurrent.ScheduledExecutorService;
5051
import java.util.concurrent.TimeUnit;
@@ -379,8 +380,9 @@ private void updateNodeStatus(NodeStatus status, Runnable healthCheck) {
379380
.build();
380381

381382
LOG.log(getDebugLogLevel(), "Running health check for Node " + status.getExternalUri());
382-
Executors.newSingleThreadExecutor()
383-
.submit(() -> Failsafe.with(initialHealthCheckPolicy).run(healthCheck::run));
383+
ExecutorService executor = Executors.newSingleThreadExecutor();
384+
executor.submit(() -> Failsafe.with(initialHealthCheckPolicy).run(healthCheck::run));
385+
executor.shutdown();
384386
}
385387
}
386388

java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import dev.failsafe.RetryPolicy;
3333
import java.util.Collections;
3434
import java.util.Set;
35+
import java.util.concurrent.ExecutorService;
3536
import java.util.concurrent.Executors;
3637
import java.util.concurrent.atomic.AtomicBoolean;
3738
import java.util.logging.Level;
@@ -200,25 +201,26 @@ public NettyServer start() {
200201
.build();
201202

202203
LOG.info("Starting registration process for Node " + node.getUri());
203-
Executors.newSingleThreadExecutor()
204-
.submit(
205-
() -> {
206-
Failsafe.with(registrationPolicy)
207-
.run(
208-
() -> {
209-
if (nodeRegistered.get()) {
210-
throw new InterruptedException("Stopping registration thread.");
211-
}
212-
HealthCheck.Result check = node.getHealthCheck().check();
213-
if (DOWN.equals(check.getAvailability())) {
214-
LOG.severe("Node is not alive: " + check.getMessage());
215-
// Throw an exception to force another check sooner.
216-
throw new UnsupportedOperationException("Node cannot be registered");
217-
}
218-
bus.fire(new NodeStatusEvent(node.getStatus()));
219-
LOG.info("Sending registration event...");
220-
});
221-
});
204+
ExecutorService executor = Executors.newSingleThreadExecutor();
205+
executor.submit(
206+
() -> {
207+
Failsafe.with(registrationPolicy)
208+
.run(
209+
() -> {
210+
if (nodeRegistered.get()) {
211+
throw new InterruptedException("Stopping registration thread.");
212+
}
213+
HealthCheck.Result check = node.getHealthCheck().check();
214+
if (DOWN.equals(check.getAvailability())) {
215+
LOG.severe("Node is not alive: " + check.getMessage());
216+
// Throw an exception to force another check sooner.
217+
throw new UnsupportedOperationException("Node cannot be registered");
218+
}
219+
bus.fire(new NodeStatusEvent(node.getStatus()));
220+
LOG.info("Sending registration event...");
221+
});
222+
});
223+
executor.shutdown();
222224

223225
return this;
224226
}

0 commit comments

Comments
 (0)