From 08689422177d9f6a4ee7428e7cc0e39f60e6bb31 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal Date: Mon, 22 Aug 2011 22:47:08 +0530 Subject: Modified to make sure that the SSH connection is closed in all possible scenarios --- .../src/com/gluster/storage/management/gateway/utils/SshUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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() + "]"); } -- cgit