Skip to content

Commit

Permalink
Merge branch 'master' into key-arg-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Apr 17, 2024
2 parents 4bb8198 + e607593 commit 9a86cce
Show file tree
Hide file tree
Showing 13 changed files with 1,983 additions and 74 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
<type>pom</type>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -177,7 +177,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -216,7 +216,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<configuration>
<attach>true</attach>
</configuration>
Expand Down Expand Up @@ -272,7 +272,7 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
Expand Down Expand Up @@ -306,7 +306,7 @@
<!--Sign the components - this is required by maven central for releases -->
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,12 @@ public ClusterPipeline pipelined() {
}

/**
* @param doMulti param
* @return nothing
* @throws UnsupportedOperationException
*/
@Override
public Transaction multi() {
public AbstractTransaction transaction(boolean doMulti) {
throw new UnsupportedOperationException();
}
}
9 changes: 6 additions & 3 deletions src/main/java/redis/clients/jedis/JedisPubSubBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ private void process() {
onUnsubscribe(enchannel, subscribedChannels);
} else if (Arrays.equals(MESSAGE.getRaw(), resp)) {
final byte[] bchannel = (byte[]) listReply.get(1);
final byte[] bmesg = (byte[]) listReply.get(2);
final Object mesg = listReply.get(2);
final T enchannel = (bchannel == null) ? null : encode(bchannel);
final T enmesg = (bmesg == null) ? null : encode(bmesg);
onMessage(enchannel, enmesg);
if (mesg instanceof List) {
((List<byte[]>) mesg).forEach(bmesg -> onMessage(enchannel, encode(bmesg)));
} else {
onMessage(enchannel, (mesg == null) ? null : encode((byte[]) mesg));
}
} else if (Arrays.equals(PMESSAGE.getRaw(), resp)) {
final byte[] bpattern = (byte[]) listReply.get(1);
final byte[] bchannel = (byte[]) listReply.get(2);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/redis/clients/jedis/JedisSharding.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ public ShardedPipeline pipelined() {
}

/**
* @param doMulti param
* @return nothing
* @throws UnsupportedOperationException
*/
@Override
public Transaction multi() {
public AbstractTransaction transaction(boolean doMulti) {
throw new UnsupportedOperationException();
}
}
14 changes: 7 additions & 7 deletions src/main/java/redis/clients/jedis/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ public Transaction(Connection connection, boolean doMulti, boolean closeConnecti
this(connection, doMulti, closeConnection, createCommandObjects(connection));
}

private static CommandObjects createCommandObjects(Connection connection) {
CommandObjects commandObjects = new CommandObjects();
RedisProtocol proto = connection.getRedisProtocol();
if (proto != null) commandObjects.setProtocol(proto);
return commandObjects;
}

/**
* Creates a new transaction.
*
Expand All @@ -103,6 +96,13 @@ private static CommandObjects createCommandObjects(Connection connection) {
if (doMulti) multi();
}

private static CommandObjects createCommandObjects(Connection connection) {
CommandObjects commandObjects = new CommandObjects();
RedisProtocol proto = connection.getRedisProtocol();
if (proto != null) commandObjects.setProtocol(proto);
return commandObjects;
}

@Override
public final void multi() {
connection.sendCommand(MULTI);
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4878,13 +4878,24 @@ public PipelineBase pipelined() {
}
}

/**
* @return transaction object
*/
public AbstractTransaction multi() {
return transaction(true);
}

/**
* @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
* @return transaction object
*/
public AbstractTransaction transaction(boolean doMulti) {
if (provider == null) {
throw new IllegalStateException("It is not allowed to create Pipeline from this " + getClass());
throw new IllegalStateException("It is not allowed to create Transaction from this " + getClass());
} else if (provider instanceof MultiClusterPooledConnectionProvider) {
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, true, commandObjects);
return new MultiClusterTransaction((MultiClusterPooledConnectionProvider) provider, doMulti, commandObjects);
} else {
return new Transaction(provider.getConnection(), true, true, commandObjects);
return new Transaction(provider.getConnection(), doMulti, true, commandObjects);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testSendCommandWithProtocolCommandAndByteArrayArgs() {
byte[][] args = { "arg1".getBytes(), "arg2".getBytes() };
CommandArguments commandArguments = mock(CommandArguments.class);
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);

when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
when(commandExecutor.executeCommand(any())).thenReturn("OK");
Expand Down Expand Up @@ -74,7 +74,7 @@ public void testSendBlockingCommandWithProtocolCommandAndByteArrayArgs() {
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
when(commandArgumentsWithArgs.blocking()).thenReturn(commandArgumentsBlocking);

when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);

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

when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
when(commandExecutor.executeCommand(any())).thenReturn("OK");
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testSendBlockingCommandWithProtocolCommandAndStringArgs() {
CommandArguments commandArgumentsWithArgs = mock(CommandArguments.class);
when(commandArgumentsWithArgs.blocking()).thenReturn(commandArgumentsBlocking);

when(commandArguments.addObjects(args)).thenReturn(commandArgumentsWithArgs);
when(commandArguments.addObjects((Object[]) args)).thenReturn(commandArgumentsWithArgs);

when(commandObjects.commandArguments(cmd)).thenReturn(commandArguments);
when(commandExecutor.executeCommand(any())).thenReturn("OK");
Expand Down
Loading

0 comments on commit 9a86cce

Please sign in to comment.