@@ -307,19 +307,21 @@ private void openConnections(ConnectionTracker tracker, Iterable<RedisURI> redis
307
307
308
308
for (RedisURI redisURI : redisURIs ) {
309
309
310
- if (redisURI .getHost () == null || tracker .contains (redisURI ) || !isEventLoopActive ()) {
311
- continue ;
312
- }
310
+ CompletableFuture <StatefulRedisConnection <String , String >> sync = new CompletableFuture <>();
313
311
314
312
try {
313
+
314
+ if (redisURI .getHost () == null || tracker .contains (redisURI ) || !isEventLoopActive ()) {
315
+ continue ;
316
+ }
317
+
315
318
SocketAddress socketAddress = clientResources .socketAddressResolver ().resolve (redisURI );
316
319
317
320
ConnectionFuture <StatefulRedisConnection <String , String >> connectionFuture = nodeConnectionFactory
318
321
.connectToNodeAsync (StringCodec .UTF8 , socketAddress );
319
322
320
323
// Note: timeout skew due to potential socket address resolution and connection work possible.
321
324
322
- CompletableFuture <StatefulRedisConnection <String , String >> sync = new CompletableFuture <>();
323
325
Timeout cancelTimeout = clientResources .timer ().newTimeout (it -> {
324
326
325
327
String message = String .format ("Unable to connect to [%s]: Timeout after %s" , socketAddress ,
@@ -360,7 +362,10 @@ private void openConnections(ConnectionTracker tracker, Iterable<RedisURI> redis
360
362
361
363
tracker .addConnection (redisURI , sync );
362
364
} catch (RuntimeException e ) {
363
- logger .warn (String .format ("Unable to connect to [%s]" , redisURI ), e );
365
+ String message = String .format ("Unable to connect to [%s]" , redisURI );
366
+ logger .warn (message , e );
367
+ sync .completeExceptionally (new RedisConnectionException (message , e ));
368
+ tracker .addConnection (redisURI , sync );
364
369
}
365
370
}
366
371
}
0 commit comments