Check jedis is connected before executing commands

This commit is contained in:
Jonathan Leibiusky
2010-06-15 23:28:19 -03:00
parent 0920223ef2
commit dc07d70e7a
4 changed files with 22 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -23,7 +23,7 @@ public class Jedis extends Client {
return sendCommand("GET", key).getBulkReply();
}
public void quit() {
public void quit() throws JedisException {
sendCommand("QUIT");
}