Fix indentation (code formatting...)
This commit is contained in:
@@ -22,11 +22,10 @@ import redis.clients.util.SafeEncoder;
|
||||
public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
MultiKeyBinaryCommands, AdvancedBinaryJedisCommands,
|
||||
BinaryScriptingCommands, Closeable {
|
||||
|
||||
protected Client client = null;
|
||||
protected Transaction transaction = null;
|
||||
protected Pipeline pipeline = null;
|
||||
|
||||
|
||||
public BinaryJedis(final String host) {
|
||||
URI uri = URI.create(host);
|
||||
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
|
||||
@@ -1771,10 +1770,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
public List<Object> multi(final TransactionBlock jedisTransaction) {
|
||||
List<Object> results = null;
|
||||
jedisTransaction.setClient(client);
|
||||
client.multi();
|
||||
client.getOne(); // expected OK
|
||||
jedisTransaction.execute();
|
||||
results = jedisTransaction.exec();
|
||||
client.multi();
|
||||
client.getOne(); // expected OK
|
||||
jedisTransaction.execute();
|
||||
results = jedisTransaction.exec();
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -1794,24 +1793,24 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
}
|
||||
|
||||
public void resetState() {
|
||||
if (client.isConnected()) {
|
||||
if (transaction != null) {
|
||||
transaction.clear();
|
||||
}
|
||||
if (client.isConnected()) {
|
||||
if (transaction != null) {
|
||||
transaction.clear();
|
||||
}
|
||||
|
||||
if (pipeline != null) {
|
||||
pipeline.clear();
|
||||
}
|
||||
if (pipeline != null) {
|
||||
pipeline.clear();
|
||||
}
|
||||
|
||||
if (client.isInWatch()) {
|
||||
unwatch();
|
||||
}
|
||||
if (client.isInWatch()) {
|
||||
unwatch();
|
||||
}
|
||||
|
||||
client.resetState();
|
||||
}
|
||||
client.resetState();
|
||||
}
|
||||
|
||||
transaction = null;
|
||||
pipeline = null;
|
||||
transaction = null;
|
||||
pipeline = null;
|
||||
}
|
||||
|
||||
public String watch(final byte[]... keys) {
|
||||
|
||||
@@ -231,42 +231,42 @@ public class Connection implements Closeable {
|
||||
}
|
||||
|
||||
public Object getOne() {
|
||||
flush();
|
||||
return readProtocolWithCheckingBroken();
|
||||
flush();
|
||||
return readProtocolWithCheckingBroken();
|
||||
}
|
||||
|
||||
public boolean isBroken() {
|
||||
return broken;
|
||||
return broken;
|
||||
}
|
||||
|
||||
protected void flush() {
|
||||
try {
|
||||
outputStream.flush();
|
||||
} catch (IOException ex) {
|
||||
broken = true;
|
||||
throw new JedisConnectionException(ex);
|
||||
}
|
||||
try {
|
||||
outputStream.flush();
|
||||
} catch (IOException ex) {
|
||||
broken = true;
|
||||
throw new JedisConnectionException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected Object readProtocolWithCheckingBroken() {
|
||||
try {
|
||||
return Protocol.read(inputStream);
|
||||
} catch (JedisConnectionException exc) {
|
||||
broken = true;
|
||||
throw exc;
|
||||
}
|
||||
try {
|
||||
return Protocol.read(inputStream);
|
||||
} catch (JedisConnectionException exc) {
|
||||
broken = true;
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> getMany(int count) {
|
||||
flush();
|
||||
List<Object> responses = new ArrayList<Object>();
|
||||
for (int i = 0 ; i < count ; i++) {
|
||||
try {
|
||||
responses.add(readProtocolWithCheckingBroken());
|
||||
} catch (JedisDataException e) {
|
||||
responses.add(e);
|
||||
}
|
||||
}
|
||||
return responses;
|
||||
flush();
|
||||
List<Object> responses = new ArrayList<Object>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
try {
|
||||
responses.add(readProtocolWithCheckingBroken());
|
||||
} catch (JedisDataException e) {
|
||||
responses.add(e);
|
||||
}
|
||||
}
|
||||
return responses;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,15 +70,15 @@ public class Pipeline extends MultiKeyPipelineBase {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (isInMulti()) {
|
||||
discard();
|
||||
}
|
||||
if (isInMulti()) {
|
||||
discard();
|
||||
}
|
||||
|
||||
sync();
|
||||
sync();
|
||||
}
|
||||
|
||||
public boolean isInMulti() {
|
||||
return currentMulti != null;
|
||||
return currentMulti != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ package redis.clients.jedis;
|
||||
* @see https://github.com/xetorthio/jedis/pull/498
|
||||
*/
|
||||
public abstract class PipelineBlock extends Pipeline {
|
||||
// For shadowing
|
||||
@SuppressWarnings("unused")
|
||||
private Client client;
|
||||
|
||||
// For shadowing
|
||||
@SuppressWarnings("unused")
|
||||
private Client client;
|
||||
|
||||
public abstract void execute();
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class Queable {
|
||||
}
|
||||
|
||||
protected boolean hasPipelinedResponse() {
|
||||
return pipelinedResponses.size() > 0;
|
||||
return pipelinedResponses.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
protected int getPipelinedResponseLength() {
|
||||
return pipelinedResponses.size();
|
||||
return pipelinedResponses.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ public class Transaction extends MultiKeyPipelineBase {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (inTransaction) {
|
||||
discard();
|
||||
}
|
||||
if (inTransaction) {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> exec() {
|
||||
@@ -60,7 +60,7 @@ public class Transaction extends MultiKeyPipelineBase {
|
||||
public List<Response<?>> execGetResponse() {
|
||||
// Discard QUEUED or ERROR
|
||||
client.getMany(getPipelinedResponseLength());
|
||||
client.exec();
|
||||
client.exec();
|
||||
|
||||
List<Object> unformatted = client.getObjectMultiBulkReply();
|
||||
if (unformatted == null) {
|
||||
@@ -81,8 +81,8 @@ public class Transaction extends MultiKeyPipelineBase {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public void setClient(Client client) {
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,10 +9,10 @@ import redis.clients.jedis.exceptions.JedisException;
|
||||
* @see https://github.com/xetorthio/jedis/pull/498
|
||||
*/
|
||||
public abstract class TransactionBlock extends Transaction {
|
||||
// For shadowing
|
||||
@SuppressWarnings("unused")
|
||||
private Client client;
|
||||
|
||||
// For shadowing
|
||||
@SuppressWarnings("unused")
|
||||
private Client client;
|
||||
|
||||
public TransactionBlock(Client client) {
|
||||
super(client);
|
||||
}
|
||||
@@ -23,6 +23,6 @@ public abstract class TransactionBlock extends Transaction {
|
||||
public abstract void execute() throws JedisException;
|
||||
|
||||
public void setClient(Client client) {
|
||||
super.setClient(client);
|
||||
super.setClient(client);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user