fix bug that return an empty list for #closePipeline
This commit is contained in:
@@ -237,7 +237,7 @@ public class JedisConnection implements RedisConnection {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> closePipeline() {
|
||||
if (pipeline != null) {
|
||||
List execute = pipeline.syncAndReturnAll();
|
||||
List<Object> execute = pipeline.syncAndReturnAll();
|
||||
if (execute != null && !execute.isEmpty()) {
|
||||
Exception cause = null;
|
||||
for (int i = 0; i < execute.size(); i++) {
|
||||
@@ -250,9 +250,12 @@ public class JedisConnection implements RedisConnection {
|
||||
execute.set(i, dataAccessException);
|
||||
}
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
throw new RedisPipelineException(cause, execute);
|
||||
}
|
||||
|
||||
return execute;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -64,13 +64,13 @@ public class SrpConnection implements RedisConnection {
|
||||
private PipelineTracker callback;
|
||||
private volatile SrpSubscription subscription;
|
||||
|
||||
private static class PipelineTracker implements FutureCallback<Object> {
|
||||
private static class PipelineTracker implements FutureCallback<Reply> {
|
||||
|
||||
private final List<Object> results = Collections.synchronizedList(new ArrayList<Object>());
|
||||
private final List<ListenableFuture<?>> futures = new ArrayList<ListenableFuture<?>>();
|
||||
private final List<ListenableFuture<? extends Reply>> futures = new ArrayList<ListenableFuture<? extends Reply>>();
|
||||
|
||||
public void onSuccess(Object result) {
|
||||
results.add(result);
|
||||
public void onSuccess(Reply result) {
|
||||
results.add(result.data());
|
||||
}
|
||||
|
||||
public void onFailure(Throwable t) {
|
||||
@@ -87,7 +87,7 @@ public class SrpConnection implements RedisConnection {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void addCommand(ListenableFuture<?> future) {
|
||||
public void addCommand(ListenableFuture<? extends Reply> future) {
|
||||
futures.add(future);
|
||||
Futures.addCallback(future, this);
|
||||
}
|
||||
@@ -191,6 +191,7 @@ public class SrpConnection implements RedisConnection {
|
||||
if (cause != null) {
|
||||
throw new RedisPipelineException(cause, execute);
|
||||
}
|
||||
|
||||
return execute;
|
||||
}
|
||||
}
|
||||
@@ -1882,7 +1883,7 @@ public class SrpConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
// processing method that adds a listener to the future in order to track down the results and close the pipeline
|
||||
private void pipeline(ListenableFuture<?> future) {
|
||||
private void pipeline(ListenableFuture<? extends Reply> future) {
|
||||
callback.addCommand(future);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user