Skip to content

Commit 9a86cce

Browse files
committed
Merge branch 'master' into key-arg-prefix
2 parents 4bb8198 + e607593 commit 9a86cce

13 files changed

+1983
-74
lines changed

Diff for: pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<dependency>
8080
<groupId>com.kohlschutter.junixsocket</groupId>
8181
<artifactId>junixsocket-core</artifactId>
82-
<version>2.9.0</version>
82+
<version>2.9.1</version>
8383
<type>pom</type>
8484
<scope>test</scope>
8585
</dependency>
@@ -177,7 +177,7 @@
177177
<plugin>
178178
<groupId>org.jacoco</groupId>
179179
<artifactId>jacoco-maven-plugin</artifactId>
180-
<version>0.8.11</version>
180+
<version>0.8.12</version>
181181
<executions>
182182
<execution>
183183
<goals>
@@ -216,7 +216,7 @@
216216
</plugin>
217217
<plugin>
218218
<artifactId>maven-source-plugin</artifactId>
219-
<version>3.3.0</version>
219+
<version>3.3.1</version>
220220
<configuration>
221221
<attach>true</attach>
222222
</configuration>
@@ -272,7 +272,7 @@
272272
</plugin>
273273
<plugin>
274274
<artifactId>maven-jar-plugin</artifactId>
275-
<version>3.3.0</version>
275+
<version>3.4.0</version>
276276
<configuration>
277277
<archive>
278278
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
@@ -306,7 +306,7 @@
306306
<!--Sign the components - this is required by maven central for releases -->
307307
<plugin>
308308
<artifactId>maven-gpg-plugin</artifactId>
309-
<version>3.2.2</version>
309+
<version>3.2.3</version>
310310
<configuration>
311311
<gpgArguments>
312312
<arg>--pinentry-mode</arg>

Diff for: src/main/java/redis/clients/jedis/JedisCluster.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,12 @@ public ClusterPipeline pipelined() {
258258
}
259259

260260
/**
261+
* @param doMulti param
261262
* @return nothing
262263
* @throws UnsupportedOperationException
263264
*/
264265
@Override
265-
public Transaction multi() {
266+
public AbstractTransaction transaction(boolean doMulti) {
266267
throw new UnsupportedOperationException();
267268
}
268269
}

Diff for: 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);

Diff for: 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
}

Diff for: src/main/java/redis/clients/jedis/Transaction.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ public Transaction(Connection connection, boolean doMulti, boolean closeConnecti
7575
this(connection, doMulti, closeConnection, createCommandObjects(connection));
7676
}
7777

78-
private static CommandObjects createCommandObjects(Connection connection) {
79-
CommandObjects commandObjects = new CommandObjects();
80-
RedisProtocol proto = connection.getRedisProtocol();
81-
if (proto != null) commandObjects.setProtocol(proto);
82-
return commandObjects;
83-
}
84-
8578
/**
8679
* Creates a new transaction.
8780
*
@@ -103,6 +96,13 @@ private static CommandObjects createCommandObjects(Connection connection) {
10396
if (doMulti) multi();
10497
}
10598

99+
private static CommandObjects createCommandObjects(Connection connection) {
100+
CommandObjects commandObjects = new CommandObjects();
101+
RedisProtocol proto = connection.getRedisProtocol();
102+
if (proto != null) commandObjects.setProtocol(proto);
103+
return commandObjects;
104+
}
105+
106106
@Override
107107
public final void multi() {
108108
connection.sendCommand(MULTI);

Diff for: src/main/java/redis/clients/jedis/UnifiedJedis.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -4878,13 +4878,24 @@ public PipelineBase pipelined() {
48784878
}
48794879
}
48804880

4881+
/**
4882+
* @return transaction object
4883+
*/
48814884
public AbstractTransaction multi() {
4885+
return transaction(true);
4886+
}
4887+
4888+
/**
4889+
* @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
4890+
* @return transaction object
4891+
*/
4892+
public AbstractTransaction transaction(boolean doMulti) {
48824893
if (provider == null) {
4883-
throw new IllegalStateException("It is not allowed to create Pipeline from this " + getClass());
4894+
throw new IllegalStateException("It is not allowed to create Transaction from this " + getClass());
48844895
} else if (provider instanceof MultiClusterPooledConnectionProvider) {
4885-
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, true, commandObjects);
4896+
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, doMulti, commandObjects);
48864897
} else {
4887-
return new Transaction(provider.getConnection(), true, true, commandObjects);
4898+
return new Transaction(provider.getConnection(), doMulti, true, commandObjects);
48884899
}
48894900
}
48904901

Diff for: 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)