From 76b52c5ef2dc68f16c71d8195256049a67334745 Mon Sep 17 00:00:00 2001 From: Tihomir Krasimirov Mateev Date: Mon, 30 Dec 2024 15:34:30 +0100 Subject: [PATCH] Public API methods removed by mistake when introducing RedisJSON #3070 (#3108) (#3109) * Reverting some of the public constructors that were changed * Restore public contracts --- .../core/AbstractRedisAsyncCommands.java | 12 +++++++ .../core/AbstractRedisReactiveCommands.java | 12 +++++++ .../lettuce/core/RedisAsyncCommandsImpl.java | 12 ++++++- .../core/RedisReactiveCommandsImpl.java | 12 ++++++- ...RedisAdvancedClusterAsyncCommandsImpl.java | 27 ++++++++++++++ ...isAdvancedClusterReactiveCommandsImpl.java | 28 +++++++++++++++ .../core/cluster/RedisClusterClient.java | 36 +++++++++++++++++++ 7 files changed, 137 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index 8a479e6cc1..de095893fa 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -57,6 +57,7 @@ import java.util.Map; import java.util.Set; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; import static io.lettuce.core.protocol.CommandType.EXEC; import static io.lettuce.core.protocol.CommandType.GEORADIUSBYMEMBER_RO; import static io.lettuce.core.protocol.CommandType.GEORADIUS_RO; @@ -93,6 +94,7 @@ public abstract class AbstractRedisAsyncCommands implements RedisAclAsyncC * * @param connection the connection to operate on * @param codec the codec for command encoding + * @param parser the implementation of the {@link JsonParser} to use */ public AbstractRedisAsyncCommands(StatefulConnection connection, RedisCodec codec, Mono parser) { this.parser = parser; @@ -101,6 +103,16 @@ public AbstractRedisAsyncCommands(StatefulConnection connection, RedisCode this.jsonCommandBuilder = new RedisJsonCommandBuilder<>(codec, parser); } + /** + * Initialize a new instance. + * + * @param connection the connection to operate on + * @param codec the codec for command encoding + */ + public AbstractRedisAsyncCommands(StatefulConnection connection, RedisCodec codec) { + this(connection, codec, DEFAULT_JSON_PARSER); + } + @Override public RedisFuture> aclCat() { return dispatch(commandBuilder.aclCat()); diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index 0000a01b3d..1e9365821f 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -65,6 +65,7 @@ import java.util.Set; import java.util.function.Supplier; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; import static io.lettuce.core.protocol.CommandType.EXEC; import static io.lettuce.core.protocol.CommandType.GEORADIUSBYMEMBER_RO; import static io.lettuce.core.protocol.CommandType.GEORADIUS_RO; @@ -109,6 +110,7 @@ public abstract class AbstractRedisReactiveCommands * * @param connection the connection to operate on. * @param codec the codec for command encoding. + * @param parser the implementation of the {@link JsonParser} to use */ public AbstractRedisReactiveCommands(StatefulConnection connection, RedisCodec codec, Mono parser) { this.connection = connection; @@ -119,6 +121,16 @@ public AbstractRedisReactiveCommands(StatefulConnection connection, RedisC this.tracingEnabled = clientResources.tracing().isEnabled(); } + /** + * Initialize a new instance. + * + * @param connection the connection to operate on. + * @param codec the codec for command encoding. + */ + public AbstractRedisReactiveCommands(StatefulConnection connection, RedisCodec codec) { + this(connection, codec, DEFAULT_JSON_PARSER); + } + private EventExecutorGroup getScheduler() { EventExecutorGroup scheduler = this.scheduler; diff --git a/src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java b/src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java index d45215f082..87bae13e02 100644 --- a/src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java +++ b/src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java @@ -22,12 +22,22 @@ public class RedisAsyncCommandsImpl extends AbstractRedisAsyncCommands connection, RedisCodec codec, Mono parser) { super(connection, codec, parser); } + /** + * Initialize a new instance. + * + * @param connection the connection to operate on + * @param codec the codec for command encoding + */ + public RedisAsyncCommandsImpl(StatefulRedisConnection connection, RedisCodec codec) { + super(connection, codec); + } + @Override public StatefulRedisConnection getStatefulConnection() { return (StatefulRedisConnection) super.getConnection(); diff --git a/src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java b/src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java index fae12f611b..de01957391 100644 --- a/src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java +++ b/src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java @@ -22,13 +22,23 @@ public class RedisReactiveCommandsImpl extends AbstractRedisReactiveComman * * @param connection the connection to operate on. * @param codec the codec for command encoding. - * + * @param parser the implementation of the {@link JsonParser} to use */ public RedisReactiveCommandsImpl(StatefulRedisConnection connection, RedisCodec codec, Mono parser) { super(connection, codec, parser); } + /** + * Initialize a new instance. + * + * @param connection the connection to operate on. + * @param codec the codec for command encoding. + */ + public RedisReactiveCommandsImpl(StatefulRedisConnection connection, RedisCodec codec) { + super(connection, codec); + } + @Override public StatefulRedisConnection getStatefulConnection() { return (StatefulRedisConnection) super.getConnection(); diff --git a/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java b/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java index 06c9a3ee7d..840a6ef1ff 100644 --- a/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java +++ b/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java @@ -87,6 +87,7 @@ public class RedisAdvancedClusterAsyncCommandsImpl extends AbstractRedisAs * * @param connection the stateful connection * @param codec Codec used to encode/decode keys and values. + * @param parser the implementation of the {@link JsonParser} to use * @deprecated since 5.1, use * {@link #RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}. */ @@ -102,6 +103,21 @@ public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnectionImpl< * * @param connection the stateful connection * @param codec Codec used to encode/decode keys and values. + * @deprecated since 5.1, use + * {@link #RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}. + */ + @Deprecated + public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnectionImpl connection, RedisCodec codec) { + super(connection, codec); + this.codec = codec; + } + + /** + * Initialize a new connection. + * + * @param connection the stateful connection + * @param codec Codec used to encode/decode keys and values. + * @param parser the implementation of the {@link JsonParser} to use */ public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection connection, RedisCodec codec, Mono parser) { @@ -109,6 +125,17 @@ public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection connection, RedisCodec codec) { + super(connection, codec); + this.codec = codec; + } + @Override public RedisFuture clientSetname(K name) { diff --git a/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java b/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java index 0ebb1475e5..0fa184b37d 100644 --- a/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java +++ b/src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java @@ -76,6 +76,7 @@ public class RedisAdvancedClusterReactiveCommandsImpl extends AbstractRedi * * @param connection the stateful connection. * @param codec Codec used to encode/decode keys and values. + * @param parser the implementation of the {@link JsonParser} to use * @deprecated since 5.2, use * {@link #RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}. */ @@ -91,6 +92,22 @@ public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnectionIm * * @param connection the stateful connection. * @param codec Codec used to encode/decode keys and values. + * @deprecated since 5.2, use + * {@link #RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}. + */ + @Deprecated + public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnectionImpl connection, + RedisCodec codec) { + super(connection, codec); + this.codec = codec; + } + + /** + * Initialize a new connection. + * + * @param connection the stateful connection. + * @param codec Codec used to encode/decode keys and values. + * @param parser the implementation of the {@link JsonParser} to use */ public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection connection, RedisCodec codec, Mono parser) { @@ -98,6 +115,17 @@ public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection connection, RedisCodec codec) { + super(connection, codec); + this.codec = codec; + } + @Override public Mono clientSetname(K name) { diff --git a/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java b/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java index 04f10540f6..cfd0a7a80f 100644 --- a/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java +++ b/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java @@ -591,6 +591,24 @@ protected StatefulRedisConnectionImpl newStatefulRedisConnection(Re return new StatefulRedisConnectionImpl<>(channelWriter, pushHandler, codec, timeout, parser); } + /** + * Create a new instance of {@link StatefulRedisConnectionImpl} or a subclass. + *

+ * Subclasses of {@link RedisClusterClient} may override that method. + * + * @param channelWriter the channel writer + * @param pushHandler the handler for push notifications + * @param codec codec + * @param timeout default timeout + * @param Key-Type + * @param Value Type + * @return new instance of StatefulRedisConnectionImpl + */ + protected StatefulRedisConnectionImpl newStatefulRedisConnection(RedisChannelWriter channelWriter, + PushHandler pushHandler, RedisCodec codec, Duration timeout) { + return new StatefulRedisConnectionImpl<>(channelWriter, pushHandler, codec, timeout); + } + /** * Create a pub/sub connection to a redis socket address. * @@ -720,6 +738,24 @@ protected StatefulRedisClusterConnectionImpl newStatefulRedisCluste return new StatefulRedisClusterConnectionImpl(channelWriter, pushHandler, codec, timeout, parser); } + /** + * Create a new instance of {@link StatefulRedisClusterConnectionImpl} or a subclass. + *

+ * Subclasses of {@link RedisClusterClient} may override that method. + * + * @param channelWriter the channel writer + * @param pushHandler the handler for push notifications + * @param codec codec + * @param timeout default timeout + * @param Key-Type + * @param Value Type + * @return new instance of StatefulRedisClusterConnectionImpl + */ + protected StatefulRedisClusterConnectionImpl newStatefulRedisClusterConnection( + RedisChannelWriter channelWriter, ClusterPushHandler pushHandler, RedisCodec codec, Duration timeout) { + return new StatefulRedisClusterConnectionImpl(channelWriter, pushHandler, codec, timeout); + } + private Mono connect(Mono socketAddressSupplier, DefaultEndpoint endpoint, StatefulRedisClusterConnectionImpl connection, Supplier commandHandlerSupplier) {