Fixed - RBatch throws NPE with big pipeline in atomic mode. #1294

pull/1300/head
Nikita 7 years ago
parent 4e82a6eae6
commit a3e8cc95a6

@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.redisson.client.RedisRedirectException;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
@ -35,7 +36,7 @@ public class BatchCommandData<T, R> extends CommandData<T, R> implements Compara
private final AtomicReference<RedisRedirectException> redirectError = new AtomicReference<RedisRedirectException>();
public BatchCommandData(RedisCommand<T> command, Object[] params, int index) {
this(new RedissonPromise<R>(), null, command, params, index);
this(new RedissonPromise<R>(), StringCodec.INSTANCE, command, params, index);
}
public BatchCommandData(RPromise<R> promise, Codec codec, RedisCommand<T> command, Object[] params, int index) {

@ -49,6 +49,22 @@ public class RedissonBatchTest extends BaseTest {
List<?> t = batch.execute();
System.out.println(t);
}
@Test
public void testBigRequestAtomic() {
RBatch batch = redisson.createBatch();
batch.atomic();
batch.timeout(15, TimeUnit.SECONDS);
batch.retryInterval(1, TimeUnit.SECONDS);
batch.retryAttempts(5);
for (int i = 0; i < 100; i++) {
batch.getBucket("" + i).setAsync(i);
batch.getBucket("" + i).getAsync();
}
BatchResult<?> s = batch.execute();
assertThat(s.getResponses().size()).isEqualTo(200);
}
@Test
public void testSyncSlaves() throws FailedToStartRedisException, IOException, InterruptedException {

Loading…
Cancel
Save