Fixed - Batch in ExecutionMode.REDIS_WRITE_ATOMIC and ExecutionMode.REDIS_READ_ATOMIC returns QUEUED instead of real result #1522

pull/1547/head
Nikita 7 years ago
parent b325d3ca09
commit 84dca69db2

@ -327,7 +327,10 @@ public class CommandBatchService extends CommandAsyncService {
ChannelFuture future = connection.send(new CommandsData(main, list, new ArrayList(entry.getCommands())));
details.setWriteFuture(future);
} else {
ChannelFuture future = connection.send(new CommandData<V, R>(details.getAttemptPromise(), details.getCodec(), details.getCommand(), details.getParams()));
RPromise<Void> main = new RedissonPromise<Void>();
List<CommandData<?, ?>> list = new LinkedList<CommandData<?, ?>>();
list.add(new CommandData<V, R>(details.getAttemptPromise(), details.getCodec(), details.getCommand(), details.getParams()));
ChannelFuture future = connection.send(new CommandsData(main, list, true));
details.setWriteFuture(future);
}
}
@ -408,7 +411,9 @@ public class CommandBatchService extends CommandAsyncService {
}
if (commands.isEmpty()) {
return RedissonPromise.newSucceededFuture(null);
executed.set(true);
BatchResult<Object> result = new BatchResult<Object>(Collections.emptyList(), 0);
return (RFuture<R>) RedissonPromise.newSucceededFuture(result);
}
if (this.options == null) {

@ -96,6 +96,14 @@ public class RedissonBatchTest extends BaseTest {
assertThat(set.getScore("abc")).isEqualTo(1d);
RBucket<String> bucket = redisson.getBucket("test");
assertThat(bucket.get()).isEqualTo("1");
RBatch batch2 = redisson.createBatch(batchOptions);
RFuture<Double> b2f1 = batch2.getScoredSortedSet("myZKey2").addScoreAsync("abc", 1d);
RFuture<Double> b2f2 = batch2.getScoredSortedSet("myZKey2").addScoreAsync("abc", 1d);
batch2.execute();
assertThat(b2f1.get()).isEqualTo(1d);
assertThat(b2f2.get()).isEqualTo(2d);
}
@Test

Loading…
Cancel
Save