You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/01/20 10:05:22 UTC

[2/2] camel git commit: CAMEL-10727: Fixed NPE in sftp with known host config stuff. Thanks to Johan Vandeweerd for reporting.

CAMEL-10727: Fixed NPE in sftp with known host config stuff. Thanks to Johan Vandeweerd for reporting.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2e716342
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2e716342
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2e716342

Branch: refs/heads/camel-2.18.x
Commit: 2e716342cb840eb9bebedcbcf3f824daf7c73dc3
Parents: 57e8d6d
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jan 20 11:03:53 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jan 20 11:04:29 2017 +0100

----------------------------------------------------------------------
 .../apache/camel/component/file/remote/SftpOperations.java  | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2e716342/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index bb0ffba..24480d7 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -262,7 +262,7 @@ public class SftpOperations implements RemoteFileOperations<ChannelSftp.LsEntry>
         }
 
         if (isNotEmpty(sftpConfig.getKnownHostsUri())) {
-            LOG.debug("Using knownhosts uri: {}", sftpConfig.getKnownHostsUri());
+            LOG.debug("Using known hosts uri: {}", sftpConfig.getKnownHostsUri());
             try {
                 InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(endpoint.getCamelContext(), sftpConfig.getKnownHostsUri());
                 jsch.setKnownHosts(is);
@@ -272,7 +272,7 @@ public class SftpOperations implements RemoteFileOperations<ChannelSftp.LsEntry>
         }
 
         if (sftpConfig.getKnownHosts() != null) {
-            LOG.debug("Using knownhosts information from byte array");
+            LOG.debug("Using known hosts information from byte array");
             jsch.setKnownHosts(new ByteArrayInputStream(sftpConfig.getKnownHosts()));
         }
 
@@ -281,7 +281,10 @@ public class SftpOperations implements RemoteFileOperations<ChannelSftp.LsEntry>
             knownHostsFile = System.getProperty("user.home") + "/.ssh/known_hosts";
             LOG.info("Known host file not configured, using user known host file: {}", knownHostsFile);
         }
-        jsch.setKnownHosts(ObjectHelper.isEmpty(knownHostsFile) ? null : knownHostsFile);
+        if (ObjectHelper.isNotEmpty(knownHostsFile)) {
+            LOG.debug("Using known hosts information from file: {}", knownHostsFile);
+            jsch.setKnownHosts(knownHostsFile);
+        }
 
         final Session session = jsch.getSession(configuration.getUsername(), configuration.getHost(), configuration.getPort());