Skip to content

Commit 279849f

Browse files
chore: remove usage of deprecated connection methods in command APIs in integration tests (#3328) (#3343)
* chore: remove usage of deprecated connection methods in command API in client, pubsub, advanced cluster and at most one integration tests Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove flushCommands and setAutoFlushCommands and it's implementations from async commands API Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: refactor integration tests removing usage of deprecated connection methods from command APIs Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove usage of deprecated isOpen and getStatefulConnection methods in integration tests Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove usage of deprecated isOpen in advanced cluster async commands API impl Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove usage of deprecated isOpen method from integration tests Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove deprecated isOpen, etc. from sentinel command APIs Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * chore: remove deprecated isOpen and close from async, reactive, sync and cluster command APIs Signed-off-by: The-East-Wind <hariatul1998@gmail.com> * Formatting issues after rebasing Formatting * A few more places where the deprecated methods needed to be removed * One last place omitted --------- Signed-off-by: The-East-Wind <hariatul1998@gmail.com> Co-authored-by: Tihomir Mateev <tihomir.mateev@gmail.com>
1 parent e15360f commit 279849f

File tree

35 files changed

+798
-1167
lines changed

35 files changed

+798
-1167
lines changed

src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,6 @@ public RedisFuture<List<Map<String, Object>>> functionList(String libraryName) {
11131113
return dispatch(commandBuilder.functionList(libraryName));
11141114
}
11151115

1116-
@Override
1117-
public void flushCommands() {
1118-
connection.flushCommands();
1119-
}
1120-
11211116
@Override
11221117
public RedisFuture<String> flushall() {
11231118
return dispatch(commandBuilder.flushall());
@@ -1553,11 +1548,6 @@ public RedisFuture<String> info(String section) {
15531548
return dispatch(commandBuilder.info(section));
15541549
}
15551550

1556-
@Override
1557-
public boolean isOpen() {
1558-
return connection.isOpen();
1559-
}
1560-
15611551
@Override
15621552
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<FieldArgs<K>> fieldArgs) {
15631553
return dispatch(searchCommandBuilder.ftCreate(index, options, fieldArgs));
@@ -2603,11 +2593,6 @@ public RedisFuture<V> setGet(K key, V value, SetArgs setArgs) {
26032593
return dispatch(commandBuilder.setGet(key, value, setArgs));
26042594
}
26052595

2606-
@Override
2607-
public void setAutoFlushCommands(boolean autoFlush) {
2608-
connection.setAutoFlushCommands(autoFlush);
2609-
}
2610-
26112596
@Override
26122597
public void setTimeout(Duration timeout) {
26132598
connection.setTimeout(timeout);

src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,6 @@ public Mono<Long> clientUnblock(long id, UnblockType type) {
492492
return createMono(() -> commandBuilder.clientUnblock(id, type));
493493
}
494494

495-
public void close() {
496-
connection.close();
497-
}
498-
499495
@Override
500496
public Mono<String> clusterAddSlots(int... slots) {
501497
return createMono(() -> commandBuilder.clusterAddslots(slots));
@@ -1177,11 +1173,6 @@ public Flux<Map<String, Object>> functionList(String libraryName) {
11771173
return createDissolvingFlux(() -> commandBuilder.functionList(libraryName));
11781174
}
11791175

1180-
@Override
1181-
public void flushCommands() {
1182-
connection.flushCommands();
1183-
}
1184-
11851176
@Override
11861177
public Mono<String> flushall() {
11871178
return createMono(commandBuilder::flushall);
@@ -1618,11 +1609,6 @@ public Mono<String> info(String section) {
16181609
return createMono(() -> commandBuilder.info(section));
16191610
}
16201611

1621-
@Override
1622-
public boolean isOpen() {
1623-
return connection.isOpen();
1624-
}
1625-
16261612
@Override
16271613
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<FieldArgs<K>> fieldArgs) {
16281614
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fieldArgs));
@@ -2688,11 +2674,6 @@ public Mono<V> setGet(K key, V value, SetArgs setArgs) {
26882674
return createMono(() -> commandBuilder.setGet(key, value, setArgs));
26892675
}
26902676

2691-
@Override
2692-
public void setAutoFlushCommands(boolean autoFlush) {
2693-
connection.setAutoFlushCommands(autoFlush);
2694-
}
2695-
26962677
@Override
26972678
public void setTimeout(Duration timeout) {
26982679
connection.setTimeout(timeout);

src/main/java/io/lettuce/core/api/async/BaseRedisAsyncCommands.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -188,34 +188,4 @@ public interface BaseRedisAsyncCommands<K, V> {
188188
*/
189189
<T> RedisFuture<T> dispatch(ProtocolKeyword type, CommandOutput<K, V, T> output, CommandArgs<K, V> args);
190190

191-
/**
192-
* @return {@code true} if the connection is open (connected and not closed).
193-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#isOpen()} method on the
194-
* connection interface. To be removed with Lettuce 7.0.
195-
*/
196-
@Deprecated
197-
boolean isOpen();
198-
199-
/**
200-
* Disable or enable auto-flush behavior. Default is {@code true}. If autoFlushCommands is disabled, multiple commands can
201-
* be issued without writing them actually to the transport. Commands are buffered until a {@link #flushCommands()} is
202-
* issued. After calling {@link #flushCommands()} commands are sent to the transport and executed by Redis.
203-
*
204-
* @param autoFlush state of autoFlush.
205-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#setAutoFlushCommands(boolean)}
206-
* method on the connection interface. To be removed with Lettuce 7.0.
207-
*/
208-
@Deprecated
209-
void setAutoFlushCommands(boolean autoFlush);
210-
211-
/**
212-
* Flush pending commands. This commands forces a flush on the channel and can be used to buffer ("pipeline") commands to
213-
* achieve batching. No-op if channel is not connected.
214-
*
215-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#flushCommands()} method on the
216-
* connection interface. To be removed with Lettuce 7.0.
217-
*/
218-
@Deprecated
219-
void flushCommands();
220-
221191
}

src/main/java/io/lettuce/core/api/reactive/BaseRedisReactiveCommands.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,6 @@ public interface BaseRedisReactiveCommands<K, V> {
189189
*/
190190
<T> Flux<T> dispatch(ProtocolKeyword type, CommandOutput<K, V, ?> output, CommandArgs<K, V> args);
191191

192-
/**
193-
* @return {@code true} if the connection is open (connected and not closed).
194-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#isOpen()} method on the
195-
* connection interface. To be removed with Lettuce 7.0.
196-
*/
197-
@Deprecated
198-
boolean isOpen();
199-
200-
/**
201-
* Disable or enable auto-flush behavior. Default is {@code true}. If autoFlushCommands is disabled, multiple commands can
202-
* be issued without writing them actually to the transport. Commands are buffered until a {@link #flushCommands()} is
203-
* issued. After calling {@link #flushCommands()} commands are sent to the transport and executed by Redis.
204-
*
205-
* @param autoFlush state of autoFlush.
206-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#setAutoFlushCommands(boolean)}
207-
* method on the connection interface. To be removed with Lettuce 7.0.
208-
*/
209-
@Deprecated
210-
void setAutoFlushCommands(boolean autoFlush);
211-
212-
/**
213-
* Flush pending commands. This commands forces a flush on the channel and can be used to buffer ("pipeline") commands to
214-
* achieve batching. No-op if channel is not connected.
215-
*
216-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#flushCommands()} method on the
217-
* connection interface. To be removed with Lettuce 7.0.
218-
*/
219-
@Deprecated
220-
void flushCommands();
221-
222192
/**
223193
* @return the currently configured instance of the {@link JsonParser}
224194
* @since 6.5

src/main/java/io/lettuce/core/api/sync/BaseRedisCommands.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,4 @@ public interface BaseRedisCommands<K, V> {
187187
*/
188188
<T> T dispatch(ProtocolKeyword type, CommandOutput<K, V, T> output, CommandArgs<K, V> args);
189189

190-
/**
191-
* @return {@code true} if the connection is open (connected and not closed).
192-
* @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#isOpen()} method on the
193-
* connection interface. To be removed with Lettuce 7.0.
194-
*/
195-
@Deprecated
196-
boolean isOpen();
197-
198190
}

src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ public RedisFuture<String> clientSetname(K name) {
148148

149149
RedisURI uri = redisClusterNode.getUri();
150150

151-
CompletableFuture<RedisClusterAsyncCommands<K, V>> byNodeId = getConnectionAsync(redisClusterNode.getNodeId());
151+
CompletableFuture<StatefulRedisConnection<K, V>> byNodeId = getStatefulConnection(redisClusterNode.getNodeId());
152152

153153
executions.put("NodeId: " + redisClusterNode.getNodeId(), byNodeId.thenCompose(c -> {
154154

155155
if (c.isOpen()) {
156-
return c.clientSetname(name);
156+
return c.async().clientSetname(name);
157157
}
158158
return ok;
159159
}));
160160

161-
CompletableFuture<RedisClusterAsyncCommands<K, V>> byHost = getConnectionAsync(uri.getHost(), uri.getPort());
161+
CompletableFuture<StatefulRedisConnection<K, V>> byHost = getStatefulConnection(uri.getHost(), uri.getPort());
162162

163163
executions.put("HostAndPort: " + redisClusterNode.getNodeId(), byHost.thenCompose(c -> {
164164

165165
if (c.isOpen()) {
166-
return c.clientSetname(name);
166+
return c.async().clientSetname(name);
167167
}
168168
return ok;
169169
}));
@@ -596,9 +596,12 @@ public RedisClusterAsyncCommands<K, V> getConnection(String host, int port) {
596596
return getStatefulConnection().getConnection(host, port).async();
597597
}
598598

599-
private CompletableFuture<RedisClusterAsyncCommands<K, V>> getConnectionAsync(String nodeId) {
600-
return getConnectionProvider().<K, V> getConnectionAsync(ConnectionIntent.WRITE, nodeId)
601-
.thenApply(StatefulRedisConnection::async);
599+
private CompletableFuture<StatefulRedisConnection<K, V>> getStatefulConnection(String nodeId) {
600+
return getConnectionProvider().getConnectionAsync(ConnectionIntent.WRITE, nodeId);
601+
}
602+
603+
private CompletableFuture<StatefulRedisConnection<K, V>> getStatefulConnection(String host, int port) {
604+
return getConnectionProvider().getConnectionAsync(ConnectionIntent.WRITE, host, port);
602605
}
603606

604607
private CompletableFuture<RedisClusterAsyncCommands<K, V>> getConnectionAsync(String host, int port) {

src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,23 @@ public Mono<String> clientSetname(K name) {
136136

137137
for (RedisClusterNode redisClusterNode : getStatefulConnection().getPartitions()) {
138138

139-
Mono<RedisClusterReactiveCommands<K, V>> byNodeId = getConnectionReactive(redisClusterNode.getNodeId());
139+
Mono<StatefulRedisConnection<K, V>> byNodeId = getStatefulConnection(redisClusterNode.getNodeId());
140140

141141
publishers.add(byNodeId.flatMap(conn -> {
142142

143143
if (conn.isOpen()) {
144-
return conn.clientSetname(name);
144+
return conn.reactive().clientSetname(name);
145145
}
146146
return Mono.empty();
147147
}));
148148

149-
Mono<RedisClusterReactiveCommands<K, V>> byHost = getConnectionReactive(redisClusterNode.getUri().getHost(),
149+
Mono<StatefulRedisConnection<K, V>> byHost = getStatefulConnection(redisClusterNode.getUri().getHost(),
150150
redisClusterNode.getUri().getPort());
151151

152152
publishers.add(byHost.flatMap(conn -> {
153153

154154
if (conn.isOpen()) {
155-
return conn.clientSetname(name);
155+
return conn.reactive().clientSetname(name);
156156
}
157157
return Mono.empty();
158158
}));
@@ -441,6 +441,10 @@ public RedisClusterReactiveCommands<K, V> getConnection(String nodeId) {
441441
return getStatefulConnection().getConnection(nodeId).reactive();
442442
}
443443

444+
private Mono<StatefulRedisConnection<K, V>> getStatefulConnection(String nodeId) {
445+
return getMono(getConnectionProvider().getConnectionAsync(ConnectionIntent.WRITE, nodeId));
446+
}
447+
444448
private Mono<RedisClusterReactiveCommands<K, V>> getConnectionReactive(String nodeId) {
445449
return getMono(getConnectionProvider().<K, V> getConnectionAsync(ConnectionIntent.WRITE, nodeId))
446450
.map(StatefulRedisConnection::reactive);
@@ -456,6 +460,10 @@ private Mono<RedisClusterReactiveCommands<K, V>> getConnectionReactive(String ho
456460
.map(StatefulRedisConnection::reactive);
457461
}
458462

463+
private Mono<StatefulRedisConnection<K, V>> getStatefulConnection(String host, int port) {
464+
return getMono(getConnectionProvider().<K, V> getConnectionAsync(ConnectionIntent.WRITE, host, port));
465+
}
466+
459467
@Override
460468
public StatefulRedisClusterConnection<K, V> getStatefulConnection() {
461469
return (StatefulRedisClusterConnection<K, V>) super.getConnection();

src/main/java/io/lettuce/core/sentinel/RedisSentinelAsyncCommandsImpl.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,6 @@ public <T> AsyncCommand<K, V, T> dispatch(RedisCommand<K, V, T> cmd) {
196196
return asyncCommand;
197197
}
198198

199-
public void close() {
200-
connection.close();
201-
}
202-
203-
@Override
204-
public boolean isOpen() {
205-
return connection.isOpen();
206-
}
207-
208199
@Override
209200
public StatefulRedisSentinelConnection<K, V> getStatefulConnection() {
210201
return (StatefulRedisSentinelConnection<K, V>) connection;

src/main/java/io/lettuce/core/sentinel/RedisSentinelReactiveCommandsImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,6 @@ public <T> Flux<T> dispatch(ProtocolKeyword type, CommandOutput<K, V, ?> output,
189189
return (Flux) createFlux(() -> new Command<>(type, output, args));
190190
}
191191

192-
@Override
193-
public void close() {
194-
getStatefulConnection().close();
195-
}
196-
197-
@Override
198-
public boolean isOpen() {
199-
return getStatefulConnection().isOpen();
200-
}
201-
202192
@Override
203193
public StatefulRedisSentinelConnection<K, V> getStatefulConnection() {
204194
return (StatefulRedisSentinelConnection<K, V>) super.getConnection();

src/main/java/io/lettuce/core/sentinel/api/async/RedisSentinelAsyncCommands.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ public interface RedisSentinelAsyncCommands<K, V> {
249249
*/
250250
<T> RedisFuture<T> dispatch(ProtocolKeyword type, CommandOutput<K, V, T> output, CommandArgs<K, V> args);
251251

252-
/**
253-
* @return {@code true} if the connection is open (connected and not closed).
254-
*/
255-
boolean isOpen();
256-
257252
/**
258253
* @return the underlying connection.
259254
*/

0 commit comments

Comments
 (0)