@@ -307,19 +307,21 @@ private void openConnections(ConnectionTracker tracker, Iterable<RedisURI> redis
307307
308308 for (RedisURI redisURI : redisURIs ) {
309309
310- if (redisURI .getHost () == null || tracker .contains (redisURI ) || !isEventLoopActive ()) {
311- continue ;
312- }
310+ CompletableFuture <StatefulRedisConnection <String , String >> sync = new CompletableFuture <>();
313311
314312 try {
313+
314+ if (redisURI .getHost () == null || tracker .contains (redisURI ) || !isEventLoopActive ()) {
315+ continue ;
316+ }
317+
315318 SocketAddress socketAddress = clientResources .socketAddressResolver ().resolve (redisURI );
316319
317320 ConnectionFuture <StatefulRedisConnection <String , String >> connectionFuture = nodeConnectionFactory
318321 .connectToNodeAsync (StringCodec .UTF8 , socketAddress );
319322
320323 // Note: timeout skew due to potential socket address resolution and connection work possible.
321324
322- CompletableFuture <StatefulRedisConnection <String , String >> sync = new CompletableFuture <>();
323325 Timeout cancelTimeout = clientResources .timer ().newTimeout (it -> {
324326
325327 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
360362
361363 tracker .addConnection (redisURI , sync );
362364 } 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 );
364369 }
365370 }
366371 }
0 commit comments