Check FutureResult status field instead of instanceof
This commit is contained in:
@@ -23,13 +23,14 @@ import org.springframework.core.convert.converter.Converter;
|
||||
* @author Jennifer Hickey
|
||||
*
|
||||
* @param <T>
|
||||
* The data type of the object that holds the future result (usually
|
||||
* of type Future)
|
||||
* The data type of the object that holds the future result (usually of type Future)
|
||||
*/
|
||||
abstract public class FutureResult<T> {
|
||||
|
||||
protected T resultHolder;
|
||||
|
||||
protected boolean status = false;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected Converter converter;
|
||||
|
||||
@@ -48,8 +49,7 @@ abstract public class FutureResult<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given result if a converter is specified, else returns the
|
||||
* result
|
||||
* Converts the given result if a converter is specified, else returns the result
|
||||
*
|
||||
* @param result
|
||||
* The result to convert
|
||||
@@ -68,6 +68,26 @@ abstract public class FutureResult<T> {
|
||||
return converter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this result is the status of an operation. Typically status results will be
|
||||
* discarded on conversion.
|
||||
*
|
||||
* @return true if this is a status result (i.e. OK)
|
||||
*/
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this result is the status of an operation. Typically status results will be
|
||||
* discarded on conversion.
|
||||
*
|
||||
* @status true if this is a status result (i.e. OK)
|
||||
*/
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The result of the operation
|
||||
*/
|
||||
|
||||
@@ -112,6 +112,7 @@ public class JedisConnection implements RedisConnection {
|
||||
private class JedisStatusResult extends JedisResult {
|
||||
public JedisStatusResult(Response<?> resultHolder) {
|
||||
super(resultHolder);
|
||||
setStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ public class JedisConnection implements RedisConnection {
|
||||
for(FutureResult<Response<?>> result: pipelinedResults) {
|
||||
try {
|
||||
Object data = result.get();
|
||||
if(!convertPipelineResults || !(result instanceof JedisStatusResult)) {
|
||||
if(!convertPipelineResults || !(result.isStatus())) {
|
||||
results.add(data);
|
||||
}
|
||||
}catch(JedisDataException e) {
|
||||
|
||||
@@ -110,6 +110,7 @@ public class LettuceConnection implements RedisConnection {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public LettuceStatusResult(Future resultHolder) {
|
||||
super(resultHolder);
|
||||
setStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +296,7 @@ public class LettuceConnection implements RedisConnection {
|
||||
}
|
||||
results.add(err);
|
||||
}
|
||||
else if(!convertPipelineResults || !(result instanceof LettuceStatusResult)) {
|
||||
else if(!convertPipelineResults || !(result.isStatus())) {
|
||||
results.add(result.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class SrpConnection implements RedisConnection {
|
||||
Object result = results.get(i);
|
||||
if(result instanceof Exception || !convertResults) {
|
||||
convertedResults.add(result);
|
||||
}else if(!(future instanceof SrpStatusResult)) {
|
||||
}else if(!(future.isStatus())) {
|
||||
convertedResults.add(future.convert(result));
|
||||
}
|
||||
i++;
|
||||
@@ -188,6 +188,7 @@ public class SrpConnection implements RedisConnection {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public SrpStatusResult(ListenableFuture<? extends Reply> resultHolder) {
|
||||
super(resultHolder);
|
||||
setStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user