28
28
import java .util .Set ;
29
29
import java .util .concurrent .Executors ;
30
30
import java .util .concurrent .ScheduledExecutorService ;
31
+ import java .util .concurrent .atomic .AtomicInteger ;
31
32
import java .util .function .Function ;
32
33
import java .util .function .Supplier ;
33
34
import java .util .stream .Collectors ;
@@ -112,7 +113,7 @@ public final Driver newInstance(
112
113
Supplier <Rediscovery > rediscoverySupplier ) {
113
114
requireNonNull (authTokenManager , "authTokenProvider must not be null" );
114
115
115
- var retryExecutor = eventLoopGroup != null ? eventLoopGroup : Executors . newSingleThreadScheduledExecutor ();
116
+ var retryExecutor = eventLoopGroup != null ? eventLoopGroup : retryScheduledExecutorService ();
116
117
var retryLogic = createRetryLogic (config .maxTransactionRetryTimeMillis (), retryExecutor , config .logging ());
117
118
118
119
var metricsProvider = getOrCreateMetricsProvider (config , createClock ());
@@ -128,6 +129,16 @@ public final Driver newInstance(
128
129
rediscoverySupplier );
129
130
}
130
131
132
+ private static ScheduledExecutorService retryScheduledExecutorService () {
133
+ var nextId = new AtomicInteger (1 );
134
+ return Executors .newSingleThreadScheduledExecutor (runnable -> {
135
+ var thread = new Thread (runnable );
136
+ thread .setName ("neo4jdriverretry-" + nextId .getAndIncrement ());
137
+ thread .setDaemon (true );
138
+ return thread ;
139
+ });
140
+ }
141
+
131
142
protected static MetricsProvider getOrCreateMetricsProvider (Config config , Clock clock ) {
132
143
var metricsAdapter = config .metricsAdapter ();
133
144
// This can actually only happen when someone mocks the config
0 commit comments