From 1fed2f8e018de59b48b9108ea0a18782cde225f0 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 13 Jan 2020 09:48:45 +0100 Subject: [PATCH] Pub/Sub resubscribe failures on connection activation #1201 Lettuce now logs failures of asynchronously fired commands during connection activation. --- .../pubsub/StatefulRedisPubSubConnectionImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java b/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java index a68dab1e40..684e97f3fd 100644 --- a/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java +++ b/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java @@ -22,6 +22,7 @@ import java.util.List; import io.lettuce.core.RedisChannelWriter; +import io.lettuce.core.RedisCommandExecutionException; import io.lettuce.core.RedisFuture; import io.lettuce.core.StatefulRedisConnectionImpl; import io.lettuce.core.codec.RedisCodec; @@ -29,6 +30,7 @@ import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands; import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands; import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands; +import io.netty.util.internal.logging.InternalLoggerFactory; /** * An thread-safe pub/sub connection to a Redis server. Multiple threads may share one {@link StatefulRedisPubSubConnectionImpl} @@ -40,8 +42,8 @@ * @param Value type. * @author Mark Paluch */ -public class StatefulRedisPubSubConnectionImpl extends StatefulRedisConnectionImpl implements - StatefulRedisPubSubConnection { +public class StatefulRedisPubSubConnectionImpl extends StatefulRedisConnectionImpl + implements StatefulRedisPubSubConnection { private final PubSubEndpoint endpoint; @@ -141,6 +143,13 @@ private T[] toArray(Collection c) { @Override public void activated() { super.activated(); - resubscribe(); + for (RedisFuture command : resubscribe()) { + command.exceptionally(throwable -> { + if (throwable instanceof RedisCommandExecutionException) { + InternalLoggerFactory.getInstance(getClass()).warn("Re-subscribe failed: " + command.getError()); + } + return null; + }); + } } }