Skip to content

Commit bb99c16

Browse files
authored
Merge branch 'master' into 5.2.0
2 parents 3bd45a4 + 8049b7b commit bb99c16

15 files changed

+2020
-71
lines changed

pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<dependency>
101101
<groupId>com.kohlschutter.junixsocket</groupId>
102102
<artifactId>junixsocket-core</artifactId>
103-
<version>2.9.0</version>
103+
<version>2.9.1</version>
104104
<type>pom</type>
105105
<scope>test</scope>
106106
</dependency>
@@ -199,7 +199,7 @@
199199
<plugin>
200200
<groupId>org.jacoco</groupId>
201201
<artifactId>jacoco-maven-plugin</artifactId>
202-
<version>0.8.11</version>
202+
<version>0.8.12</version>
203203
<executions>
204204
<execution>
205205
<goals>
@@ -238,7 +238,7 @@
238238
</plugin>
239239
<plugin>
240240
<artifactId>maven-source-plugin</artifactId>
241-
<version>3.3.0</version>
241+
<version>3.3.1</version>
242242
<configuration>
243243
<attach>true</attach>
244244
</configuration>
@@ -294,7 +294,7 @@
294294
</plugin>
295295
<plugin>
296296
<artifactId>maven-jar-plugin</artifactId>
297-
<version>3.3.0</version>
297+
<version>3.4.1</version>
298298
<configuration>
299299
<archive>
300300
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
@@ -328,7 +328,7 @@
328328
<!--Sign the components - this is required by maven central for releases -->
329329
<plugin>
330330
<artifactId>maven-gpg-plugin</artifactId>
331-
<version>3.2.2</version>
331+
<version>3.2.4</version>
332332
<configuration>
333333
<gpgArguments>
334334
<arg>--pinentry-mode</arg>

src/main/java/redis/clients/jedis/JedisCluster.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,12 @@ public ClusterPipeline pipelined() {
300300
}
301301

302302
/**
303+
* @param doMulti param
303304
* @return nothing
304305
* @throws UnsupportedOperationException
305306
*/
306307
@Override
307-
public Transaction multi() {
308+
public AbstractTransaction transaction(boolean doMulti) {
308309
throw new UnsupportedOperationException();
309310
}
310311
}

src/main/java/redis/clients/jedis/JedisPubSubBase.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ private void process() {
133133
onUnsubscribe(enchannel, subscribedChannels);
134134
} else if (Arrays.equals(MESSAGE.getRaw(), resp)) {
135135
final byte[] bchannel = (byte[]) listReply.get(1);
136-
final byte[] bmesg = (byte[]) listReply.get(2);
136+
final Object mesg = listReply.get(2);
137137
final T enchannel = (bchannel == null) ? null : encode(bchannel);
138-
final T enmesg = (bmesg == null) ? null : encode(bmesg);
139-
onMessage(enchannel, enmesg);
138+
if (mesg instanceof List) {
139+
((List<byte[]>) mesg).forEach(bmesg -> onMessage(enchannel, encode(bmesg)));
140+
} else {
141+
onMessage(enchannel, (mesg == null) ? null : encode((byte[]) mesg));
142+
}
140143
} else if (Arrays.equals(PMESSAGE.getRaw(), resp)) {
141144
final byte[] bpattern = (byte[]) listReply.get(1);
142145
final byte[] bchannel = (byte[]) listReply.get(2);

src/main/java/redis/clients/jedis/JedisSharding.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ public ShardedPipeline pipelined() {
5959
}
6060

6161
/**
62+
* @param doMulti param
6263
* @return nothing
6364
* @throws UnsupportedOperationException
6465
*/
6566
@Override
66-
public Transaction multi() {
67+
public AbstractTransaction transaction(boolean doMulti) {
6768
throw new UnsupportedOperationException();
6869
}
6970
}

src/main/java/redis/clients/jedis/MultiClusterClientConfig.java

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Arrays;
88
import java.util.List;
99

10+
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
1011
import redis.clients.jedis.annots.Experimental;
1112
import redis.clients.jedis.exceptions.JedisConnectionException;
1213
import redis.clients.jedis.exceptions.JedisValidationException;
@@ -177,12 +178,20 @@ public static class ClusterConfig {
177178
private int priority;
178179
private HostAndPort hostAndPort;
179180
private JedisClientConfig clientConfig;
181+
private GenericObjectPoolConfig<Connection> connectionPoolConfig;
180182

181183
public ClusterConfig(HostAndPort hostAndPort, JedisClientConfig clientConfig) {
182184
this.hostAndPort = hostAndPort;
183185
this.clientConfig = clientConfig;
184186
}
185187

188+
public ClusterConfig(HostAndPort hostAndPort, JedisClientConfig clientConfig,
189+
GenericObjectPoolConfig<Connection> connectionPoolConfig) {
190+
this.hostAndPort = hostAndPort;
191+
this.clientConfig = clientConfig;
192+
this.connectionPoolConfig = connectionPoolConfig;
193+
}
194+
186195
public int getPriority() {
187196
return priority;
188197
}
@@ -198,6 +207,10 @@ public HostAndPort getHostAndPort() {
198207
public JedisClientConfig getJedisClientConfig() {
199208
return clientConfig;
200209
}
210+
211+
public GenericObjectPoolConfig<Connection> getConnectionPoolConfig() {
212+
return connectionPoolConfig;
213+
}
201214
}
202215

203216
public static class Builder {

src/main/java/redis/clients/jedis/UnifiedJedis.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -4918,13 +4918,24 @@ public PipelineBase pipelined() {
49184918
}
49194919
}
49204920

4921+
/**
4922+
* @return transaction object
4923+
*/
49214924
public AbstractTransaction multi() {
4925+
return transaction(true);
4926+
}
4927+
4928+
/**
4929+
* @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
4930+
* @return transaction object
4931+
*/
4932+
public AbstractTransaction transaction(boolean doMulti) {
49224933
if (provider == null) {
4923-
throw new IllegalStateException("It is not allowed to create Pipeline from this " + getClass());
4934+
throw new IllegalStateException("It is not allowed to create Transaction from this " + getClass());
49244935
} else if (provider instanceof MultiClusterPooledConnectionProvider) {
4925-
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, true, commandObjects);
4936+
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, doMulti, commandObjects);
49264937
} else {
4927-
return new Transaction(provider.getConnection(), true, true);
4938+
return new Transaction(provider.getConnection(), doMulti, true);
49284939
}
49294940
}
49304941

src/main/java/redis/clients/jedis/providers/MultiClusterPooledConnectionProvider.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.util.Map;
1515
import java.util.concurrent.ConcurrentHashMap;
1616
import java.util.function.Consumer;
17+
18+
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
1719
import org.slf4j.Logger;
1820
import org.slf4j.LoggerFactory;
1921

@@ -112,6 +114,7 @@ public MultiClusterPooledConnectionProvider(MultiClusterClientConfig multiCluste
112114

113115
ClusterConfig[] clusterConfigs = multiClusterClientConfig.getClusterConfigs();
114116
for (ClusterConfig config : clusterConfigs) {
117+
GenericObjectPoolConfig<Connection> poolConfig = config.getConnectionPoolConfig();
115118

116119
String clusterId = "cluster:" + config.getPriority() + ":" + config.getHostAndPort();
117120

@@ -130,9 +133,15 @@ public MultiClusterPooledConnectionProvider(MultiClusterClientConfig multiCluste
130133
circuitBreakerEventPublisher.onSlowCallRateExceeded(event -> log.error(String.valueOf(event)));
131134
circuitBreakerEventPublisher.onStateTransition(event -> log.warn(String.valueOf(event)));
132135

133-
multiClusterMap.put(config.getPriority(),
134-
new Cluster(new ConnectionPool(config.getHostAndPort(),
135-
config.getJedisClientConfig()), retry, circuitBreaker));
136+
if (poolConfig != null) {
137+
multiClusterMap.put(config.getPriority(),
138+
new Cluster(new ConnectionPool(config.getHostAndPort(),
139+
config.getJedisClientConfig(), poolConfig), retry, circuitBreaker));
140+
} else {
141+
multiClusterMap.put(config.getPriority(),
142+
new Cluster(new ConnectionPool(config.getHostAndPort(),
143+
config.getJedisClientConfig()), retry, circuitBreaker));
144+
}
136145
}
137146

138147
/// --- ///

src/test/java/redis/clients/jedis/UnifiedJedisCustomCommandsTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testSendCommandWithProtocolCommandAndByteArrayArgs() {
4646
byte[][] args = { "arg1".getBytes(), "arg2".getBytes() };
4747
CommandArguments commandArguments = mock(CommandArguments.class);
4848
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
49-
when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
49+
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);
5050

5151
when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
5252
when(commandExecutor.executeCommand(any())).thenReturn("OK");
@@ -74,7 +74,7 @@ public void testSendBlockingCommandWithProtocolCommandAndByteArrayArgs() {
7474
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
7575
when(commandArgumentsWithArgs.blocking()).thenReturn(commandArgumentsBlocking);
7676

77-
when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
77+
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);
7878

7979
when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
8080
when(commandExecutor.executeCommand(any())).thenReturn("OK");
@@ -98,7 +98,7 @@ public void testSendCommandWithProtocolCommandAndStringArgs() {
9898
String[] args = { "arg1", "arg2" };
9999
CommandArguments commandArguments = mock(CommandArguments.class);
100100
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
101-
when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
101+
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);
102102

103103
when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
104104
when(commandExecutor.executeCommand(any())).thenReturn("OK");
@@ -126,7 +126,7 @@ public void testSendBlockingCommandWithProtocolCommandAndStringArgs() {
126126
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
127127
when(commandArgumentsWithArgs.blocking()).thenReturn(commandArgumentsBlocking);
128128

129-
when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
129+
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);
130130

131131
when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
132132
when(commandExecutor.executeCommand(any())).thenReturn("OK");

0 commit comments

Comments
 (0)