Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing UNWATCH in Transaction and Pipeline #2032

Merged
merged 2 commits into from Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/redis/clients/jedis/MultiKeyPipelineBase.java
Expand Up @@ -307,6 +307,12 @@ public Response<String> watch(byte[]... keys) {
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<String> unwatch() {
client.unwatch();
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<Long> zinterstore(String dstkey, String... sets) {
client.zinterstore(dstkey, sets);
Expand Down
Expand Up @@ -58,6 +58,8 @@ public interface MultiKeyBinaryRedisPipeline {

Response<String> watch(byte[]... keys);

Response<String> unwatch();

Response<Long> zinterstore(byte[] dstkey, byte[]... sets);

Response<Long> zinterstore(byte[] dstkey, ZParams params, byte[]... sets);
Expand Down
Expand Up @@ -57,6 +57,8 @@ public interface MultiKeyCommandsPipeline {

Response<String> watch(String... keys);

Response<String> unwatch();

Response<Long> zinterstore(String dstkey, String... sets);

Response<Long> zinterstore(String dstkey, ZParams params, String... sets);
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/redis/clients/jedis/tests/PipeliningTest.java
Expand Up @@ -308,6 +308,24 @@ public void multiWithSync() {
assertEquals("world", r3.get());
}

@Test
public void multiWithWatch() {
String key = "foo";
String val = "bar";
List<Object> expect = new ArrayList<>();
List<Object> expMulti = new ArrayList<>();

Pipeline pipe = jedis.pipelined();
pipe.set(key, val); expect.add("OK");
pipe.watch(key); expect.add("OK");
pipe.multi(); expect.add("OK");
pipe.unwatch(); expect.add("QUEUED"); expMulti.add("OK");
pipe.get(key); expect.add("QUEUED"); expMulti.add(val);
pipe.exec(); expect.add(expMulti);

assertEquals(expect, pipe.syncAndReturnAll());
}

@Test(expected = JedisDataException.class)
public void pipelineExecShoudThrowJedisDataExceptionWhenNotInMulti() {
Pipeline pipeline = jedis.pipelined();
Expand Down