summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-adaptor/provider/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config/appc-config-adaptor/provider/src/main')
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
index 3b430bf68..1f161c3b0 100644
--- a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
+++ b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/SshJcraftWrapper.java
@@ -1095,20 +1095,17 @@ public class SshJcraftWrapper {
ChannelSftp sftp = (ChannelSftp) sftpSession.openChannel("sftp");
debugLog.printRTAriDebug(fn, "Connecting....");
sftp.connect();
- InputStream in = null;
- in = sftp.get(fullFilePathName);
+ InputStream in = sftp.get(fullFilePathName);
String sftpFileString = readInputStreamAsString(in);
debugLog.printRTAriDebug(fn, "Retreived successfully");
- // debugLog.printRTAriDebug (fn, "sftpFileString="+sftpFileString);
- sftpSession.disconnect();
- sftpSession = null;
- return (sftpFileString);
+ return sftpFileString;
} catch (Exception e) {
debugLog.printRTAriDebug(fn, "Caught an Exception, e=" + e);
- sftpSession.disconnect();
- sftpSession = null;
- // dbLog.storeData("ErrorMsg= sftp threw an Exception. error is:"+e);
throw new IOException(e.toString());
+ } finally {
+ if(sftpSession != null) {
+ sftpSession.disconnect();
+ }
}
}