summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-08-22 22:47:08 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-08-22 23:07:49 +0530
commit08689422177d9f6a4ee7428e7cc0e39f60e6bb31 (patch)
tree82b096a48900b6f701e1531ddc0d595841c127aa /src
parentc4c993cf4e39dfd475bd199083f7aa3732fb494b (diff)
Modified to make sure that the SSH connection is closed in all possible scenarios
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
index b3e9072a..96c2b5fc 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
@@ -83,7 +83,7 @@ public class SshUtil {
public boolean isPublicKeyInstalled(String serverName) {
try {
- getConnection(serverName);
+ getConnectionWithPubKey(serverName).close();
return true;
} catch(ConnectionException e) {
return false;
@@ -172,6 +172,7 @@ public class SshUtil {
private synchronized Connection getConnectionWithPassword(String serverName) {
Connection conn = createConnection(serverName);
if(!authenticateWithPassword(conn)) {
+ conn.close();
throw new ConnectionException("SSH Authentication (password) failed for server ["
+ conn.getHostname() + "]");
}
@@ -181,6 +182,7 @@ public class SshUtil {
private synchronized Connection getConnectionWithPubKey(String serverName) {
Connection conn = createConnection(serverName);
if(!authenticateWithPublicKey(conn)) {
+ conn.close();
throw new ConnectionException("SSH Authentication (public key) failed for server ["
+ conn.getHostname() + "]");
}