Description
Spring integration SFTP 6.4.5
Describe the bug
When creating SftpSession using DefaultSftpSessionFactory.getSession() I observe that an authentication failure results in the underlying ClientSession still being connected to the SFTP server.
To Reproduce
Observed with a real SFTP server and using SFTPInboundChannelAdapter but also seen in small test.
// Pseudocode
// Set up test SshServer
// Set up DefaultSftpSessionFactory with no password or public key to trigger Auth failure
try (SftpSession session = sessionFactory.getSession()) {
// Ignored code due to exception in getSession()
} finally {
Thread.sleep(1000);
// Connection is not closed
assertThat(testServer.getActiveSessions(), hasSize(1));
}
Expected behavior
The call to getSession should not leave unclosed resources when failing with an IOException.
Sample
See above, apologies is difficult to directly upload my test class.