diff --git a/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java b/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java index 8052b95617..c4e6e55092 100644 --- a/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java +++ b/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java @@ -109,6 +109,7 @@ public StatefulRedisConnectionImpl(RedisChannelWriter writer, PushHandler pushHa this.reactive = newRedisReactiveCommandsImpl(); } + @Override public RedisCodec getCodec() { return codec; } diff --git a/src/main/java/io/lettuce/core/api/StatefulConnection.java b/src/main/java/io/lettuce/core/api/StatefulConnection.java index 99bbff3bd7..d9e5dd45a0 100644 --- a/src/main/java/io/lettuce/core/api/StatefulConnection.java +++ b/src/main/java/io/lettuce/core/api/StatefulConnection.java @@ -6,6 +6,7 @@ import io.lettuce.core.ClientOptions; import io.lettuce.core.RedisConnectionStateListener; +import io.lettuce.core.codec.RedisCodec; import io.lettuce.core.protocol.RedisCommand; import io.lettuce.core.resource.ClientResources; @@ -81,7 +82,7 @@ public interface StatefulConnection extends AutoCloseable, AsyncCloseable * connection will become not usable anymore as soon as this method was called. * * @return a {@link CompletableFuture} that is notified once the operation completes, either because the operation was - * successful or because of an error. + * successful or because of an error. * @since 5.1 */ @Override @@ -117,4 +118,9 @@ public interface StatefulConnection extends AutoCloseable, AsyncCloseable */ void flushCommands(); + /** + * @return the codec used for this connection. + */ + RedisCodec getCodec(); + } diff --git a/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java b/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java index d967ada1ed..a739447119 100644 --- a/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java +++ b/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java @@ -126,6 +126,11 @@ public StatefulRedisClusterConnectionImpl(RedisChannelWriter writer, ClusterPush this.reactive = newRedisAdvancedClusterReactiveCommandsImpl(); } + @Override + public RedisCodec getCodec() { + return codec; + } + protected RedisAdvancedClusterReactiveCommandsImpl newRedisAdvancedClusterReactiveCommandsImpl() { return new RedisAdvancedClusterReactiveCommandsImpl<>((StatefulRedisClusterConnection) this, codec, parser); } diff --git a/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java b/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java index 2eb2090461..b4d9744498 100644 --- a/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java +++ b/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java @@ -128,6 +128,11 @@ public ConnectionState getConnectionState() { return connectionState; } + @Override + public RedisCodec getCodec() { + return codec; + } + static class SentinelConnectionState extends ConnectionState { @Override