Check jedis is connected before executing commands
This commit is contained in:
@@ -21,7 +21,11 @@ public class Client {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
protected Client sendCommand(String name, String... args) {
|
||||
protected Client sendCommand(String name, String... args)
|
||||
throws JedisException {
|
||||
if (!isConnected()) {
|
||||
throw new JedisException("Please connect Jedis before using it.");
|
||||
}
|
||||
protocol.sendCommand(outputStream, name, args);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Jedis extends Client {
|
||||
return sendCommand("GET", key).getBulkReply();
|
||||
}
|
||||
|
||||
public void quit() {
|
||||
public void quit() throws JedisException {
|
||||
sendCommand("QUIT");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user