connect in sendCommand() and don't check with isConnected() two times

This commit is contained in:
KARASZI István
2010-09-10 19:40:44 +08:00
committed by Jonathan Leibiusky
parent a614f1ff3e
commit c6507e6187
3 changed files with 13 additions and 5 deletions

View File

@@ -50,9 +50,13 @@ public class Connection {
}
protected Connection sendCommand(String name, String... args) {
if (!isConnected()) {
throw new JedisException("Please connect Jedis before using it.");
}
try {
connect();
} catch (UnknownHostException e) {
throw new JedisException("Could not connect to redis-server", e);
} catch (IOException e) {
throw new JedisException("Could not connect to redis-server", e);
}
protocol.sendCommand(outputStream, name, args);
pipelinedCommands++;
return this;

View File

@@ -15,4 +15,8 @@ public class JedisException extends RuntimeException {
public JedisException(IOException e) {
super(e);
}
public JedisException(String message, Throwable cause) {
super(message, cause);
}
}