Skip to content

Commit c6cab73

Browse files
authored
JAVA-2932: Make DefaultDriverConfigLoader.close() resilient to terminated executors (#1557)
1 parent 4d7de91 commit c6cab73

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.11.2 (in progress)
66

7+
- [bug] JAVA-2932: Make DefaultDriverConfigLoader.close() resilient to terminated executors
78
- [bug] JAVA-2945: Reinstate InternalDriverContext.getNodeFilter method
89
- [bug] JAVA-2947: Release buffer after decoding multi-slice frame
910
- [bug] JAVA-2946: Make MapperResultProducerService instances be located with user-provided class loader

core/src/main/java/com/datastax/oss/driver/internal/core/config/typesafe/DefaultDriverConfigLoader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.time.Duration;
4040
import java.util.concurrent.CompletableFuture;
4141
import java.util.concurrent.CompletionStage;
42+
import java.util.concurrent.RejectedExecutionException;
4243
import java.util.concurrent.TimeUnit;
4344
import java.util.function.Supplier;
4445
import net.jcip.annotations.ThreadSafe;
@@ -235,8 +236,14 @@ public Supplier<Config> getConfigSupplier() {
235236
@Override
236237
public void close() {
237238
SingleThreaded singleThreaded = this.singleThreaded;
238-
if (singleThreaded != null) {
239-
RunOrSchedule.on(singleThreaded.adminExecutor, singleThreaded::close);
239+
if (singleThreaded != null && !singleThreaded.adminExecutor.terminationFuture().isDone()) {
240+
try {
241+
RunOrSchedule.on(singleThreaded.adminExecutor, singleThreaded::close);
242+
} catch (RejectedExecutionException e) {
243+
// Checking the future is racy, there is still a tiny window that could get us here.
244+
// We can safely ignore this error because, if the execution is rejected, the periodic
245+
// reload task, if any, has been already cancelled.
246+
}
240247
}
241248
}
242249

0 commit comments

Comments
 (0)