hansva opened a new issue, #9622: URL: https://github.com/apache/hop/issues/9622
### What needs to happen? `HopVfsSftpSchemeTest.sftpSchemeReadsFromEmbeddedServer` in `hop-tech-sftp` fails intermittently on GitHub Actions, usually on all three surefire tries: ``` FileSystemException: Could not determine the type of file "sftp://…@127.0.0.1:42991/greeting.txt". at AbstractFileObject.getType(AbstractFileObject.java:1387) at AbstractFileObject.exists(AbstractFileObject.java:968) at HopVfsSftpSchemeTest.sftpSchemeReadsFromEmbeddedServer(HopVfsSftpSchemeTest.java:105) Caused by: NullPointerException: Cannot invoke "com.jcraft.jsch.ChannelSftp.connect(int)" because "channel" is null at SftpFileSystem.getChannel(SftpFileSystem.java:216) at SftpFileObject.statSelf(SftpFileObject.java:598) ``` It has failed on PR builds that change nothing in SFTP or VFS, and passes on most runs. ### Cause (probable) - `SftpFileSystem.getChannel()` calls `getSession().openChannel("sftp")` and uses the result without checking it. - In JSch, `Session.openChannel()` returns `null` instead of throwing when the session is disconnecting: `addChannel()` refuses a new channel once `disconnectingChannels` is set. - `getSession()` reconnects only when `session.isConnected()` is false. If the session starts to close after that check, the channel is null and the next line throws an NPE. The test sets the embedded MINA SSHD server's idle timeout to 5 seconds, so that the open SFTP session does not keep the test running for the default 10 minutes. The test takes about 6 seconds even when it passes. So the server can close the session just as the client opens its first channel: - If the session is already fully closed, `getSession()` reconnects and the test passes. - If it is closing at that moment, the test fails. What keeps the session idle for about 5 seconds before the first channel is opened has not been found yet. ### Fix 1. **Test:** do not rely on the server's idle timeout to end the session. Use a longer idle timeout, or none, and close the SFTP file system (or stop the server immediately) in `@AfterAll`. 2. **Provider:** in `SftpFileSystem.getChannel()` (and `executeCommand()`, which uses `openChannel("exec")` the same way), treat a `null` channel as a dropped session. Reconnect once and try again. If that also fails, throw a `FileSystemException` that explains it, instead of an NPE. A real server can drop an idle session in the same way, so this also matters outside tests. ### Issue Priority Priority: 2 ### Issue Component Component: Unit Testing -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
