Repository: nifi
Updated Branches:
  refs/heads/master 69613f29c -> 91ed96f8c


NIFI-4040: Continue if SFTP failed getting user home directory

Signed-off-by: Pierre Villard <[email protected]>

This closes #1898.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/91ed96f8
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/91ed96f8
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/91ed96f8

Branch: refs/heads/master
Commit: 91ed96f8c43fece2e92f557ca56a50a48a95dfdf
Parents: 69613f2
Author: Koji Kawamura <[email protected]>
Authored: Thu Jun 8 16:10:09 2017 +0900
Committer: Pierre Villard <[email protected]>
Committed: Mon Jun 26 19:09:22 2017 +0200

----------------------------------------------------------------------
 .../nifi/processors/standard/util/SFTPTransfer.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/91ed96f8/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
index b5fa3bb..42fbf8d 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
@@ -396,7 +396,8 @@ public class SFTPTransfer implements FileTransfer {
 
         final JSch jsch = new JSch();
         try {
-            final Session session = 
jsch.getSession(ctx.getProperty(USERNAME).evaluateAttributeExpressions(flowFile).getValue(),
+            final String username = 
ctx.getProperty(USERNAME).evaluateAttributeExpressions(flowFile).getValue();
+            final Session session = jsch.getSession(username,
                 
ctx.getProperty(HOSTNAME).evaluateAttributeExpressions(flowFile).getValue(),
                 
ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger().intValue());
 
@@ -441,10 +442,16 @@ public class SFTPTransfer implements FileTransfer {
             if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) {
                 session.setServerAliveCountMax(0); // do not send keepalive 
message on SocketTimeoutException
             }
-            this.homeDir = sftp.getHome();
+            try {
+                this.homeDir = sftp.getHome();
+            } catch (SftpException e) {
+                // For some combination of server configuration and user home 
directory, getHome() can fail with "2: File not found"
+                // Since  homeDir is only used tor SEND provenance event 
transit uri, this is harmless. Log and continue.
+                logger.debug("Failed to retrieve {} home directory due to {}", 
new Object[]{username, e.getMessage()});
+            }
             return sftp;
 
-        } catch (final SftpException | JSchException e) {
+        } catch (JSchException e) {
             throw new IOException("Failed to obtain connection to remote host 
due to " + e.toString(), e);
         }
     }

Reply via email to