Fix Pipeline NPE or sth with multi
* followings are now throwing JedisDataException: it was uncontrolled or controlled by Redis itself ** exec without multi ** discard without multi ** multi within multi * updates unit test actually Redis returns ERR and we can pick, but Pipeline + multi has some complex sequence so it can just throw NPE without ERR
This commit is contained in:
@@ -104,12 +104,18 @@ public class Pipeline extends MultiKeyPipelineBase {
|
||||
}
|
||||
|
||||
public Response<String> discard() {
|
||||
if (currentMulti == null)
|
||||
throw new JedisDataException("DISCARD without MULTI");
|
||||
|
||||
client.discard();
|
||||
currentMulti = null;
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<List<Object>> exec() {
|
||||
if (currentMulti == null)
|
||||
throw new JedisDataException("EXEC without MULTI");
|
||||
|
||||
client.exec();
|
||||
Response<List<Object>> response = super.getResponse(currentMulti);
|
||||
currentMulti.setResponseDependency(response);
|
||||
@@ -118,6 +124,9 @@ public class Pipeline extends MultiKeyPipelineBase {
|
||||
}
|
||||
|
||||
public Response<String> multi() {
|
||||
if (currentMulti != null)
|
||||
throw new JedisDataException("MULTI calls can not be nested");
|
||||
|
||||
client.multi();
|
||||
Response<String> response = getResponse(BuilderFactory.STRING); // Expecting
|
||||
// OK
|
||||
|
||||
Reference in New Issue
Block a user