mirror of https://github.com/apache/nifi.git
NIFI-4040: Continue if SFTP failed getting user home directory
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #1898.
This commit is contained in:
parent
69613f29c9
commit
91ed96f8c4
|
@ -396,7 +396,8 @@ public class SFTPTransfer implements FileTransfer {
|
||||||
|
|
||||||
final JSch jsch = new JSch();
|
final JSch jsch = new JSch();
|
||||||
try {
|
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(HOSTNAME).evaluateAttributeExpressions(flowFile).getValue(),
|
||||||
ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger().intValue());
|
ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger().intValue());
|
||||||
|
|
||||||
|
@ -441,10 +442,16 @@ public class SFTPTransfer implements FileTransfer {
|
||||||
if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) {
|
if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) {
|
||||||
session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException
|
session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
this.homeDir = sftp.getHome();
|
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;
|
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);
|
throw new IOException("Failed to obtain connection to remote host due to " + e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue