add pipeline exception for Rjc
This commit is contained in:
@@ -93,7 +93,8 @@ public interface RedisConnection extends RedisCommands {
|
||||
* Executes the commands in the pipeline and returns their result.
|
||||
* If the connection is not pipelined, an empty collection is returned.
|
||||
*
|
||||
* @throws RedisPipelineException if the pipeline contains any incorrect/invalid statements
|
||||
* @return the result of the executed commands.
|
||||
*/
|
||||
List<Object> closePipeline();
|
||||
List<Object> closePipeline() throws RedisPipelineException;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
|
||||
/**
|
||||
* Exception thrown when executing/closing a pipeline that contains one or multiple invalid/incorrect statements.
|
||||
* The exception contains the pipeline result, allowing for analysis and tracing.
|
||||
* The exception might also contain the pipeline result (if the driver returns it), allowing for analysis and tracing.
|
||||
* <p/>
|
||||
* Typically, the first exception returned by the pipeline is used as the <i>cause</i> of this exception for easier
|
||||
* debugging.
|
||||
@@ -56,6 +56,15 @@ public class RedisPipelineException extends InvalidDataAccessResourceUsageExcept
|
||||
this("Pipeline contained one or more invalid commands", cause, pipelineResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RedisPipelineException</code> instance using a default message
|
||||
* and an empty pipeline result list.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public RedisPipelineException(Exception cause) {
|
||||
this("Pipeline contained one or more invalid commands", cause, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RedisPipelineException</code> instance.
|
||||
@@ -69,7 +78,7 @@ public class RedisPipelineException extends InvalidDataAccessResourceUsageExcept
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of the pipeline that caused the exception.
|
||||
* Optionally returns the result of the pipeline that caused the exception.
|
||||
* Typically contains both the results of the successful statements but also
|
||||
* the exceptions of the incorrect ones.
|
||||
*
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.data.redis.RedisSystemException;
|
||||
import org.springframework.data.redis.connection.DataType;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisPipelineException;
|
||||
import org.springframework.data.redis.connection.RedisSubscribedConnectionException;
|
||||
import org.springframework.data.redis.connection.SortParameters;
|
||||
import org.springframework.data.redis.connection.Subscription;
|
||||
@@ -142,9 +143,10 @@ public class RjcConnection implements RedisConnection {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> closePipeline() {
|
||||
if (pipeline != null) {
|
||||
List execute = client.getAll();
|
||||
if (execute != null && !execute.isEmpty()) {
|
||||
return execute;
|
||||
try {
|
||||
List execute = client.getAll();
|
||||
} catch (Exception ex) {
|
||||
throw new RedisPipelineException(convertRjcAccessException(ex));
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user