gnodet opened a new pull request, #25157:
URL: https://github.com/apache/camel/pull/25157

   ## Summary
   
   Fixes [CAMEL-24273](https://issues.apache.org/jira/browse/CAMEL-24273): 
After every SFTP transfer using `camel-mina-sftp` with `disconnect=true`, NIO2 
and timer daemon threads from the `SshClient` accumulate because `disconnect()` 
does not stop the `SshClient`. Over time this exhausts the system's 
thread/ulimit capacity.
   
   ## Root Cause
   
   `MinaSftpOperations.disconnect()` only closed the `SftpClient` and 
`ClientSession` but did **not** call `sshClient.stop()`, leaving the 
`SshClient`'s internal NIO2 thread pool, timer threads, and resume threads 
running indefinitely. The `forceDisconnect()` method already handles this 
correctly.
   
   ## Changes
   
   - **`MinaSftpOperations.disconnect()`**: Added `sshClient.stop()` and 
nulling of all connection fields (`sshClient`, `session`, `sftpClient`), 
matching what `forceDisconnect()` already does correctly.
   - **`MinaSftpOperationsDisconnectTest`** (new): Unit tests verifying that 
`disconnect()` stops the `SshClient`, nulls all connection fields, is 
idempotent, and handles never-connected state.
   - **`SftpDisconnectThreadLeakIT`** (new): Integration test that performs 
multiple SFTP transfers with `disconnect=true` and verifies no `SshClient` 
daemon threads leak.
   
   ## Test Plan
   
   - [x] Unit tests verify `SshClient` is stopped and fields are nulled after 
`disconnect()`
   - [x] Unit tests verify idempotent disconnect behavior
   - [x] Integration test verifies no thread leak after multiple SFTP transfers 
with `disconnect=true`
   - [x] All existing unit tests pass (25/25)
   - [x] Module builds cleanly with source check (`-Psourcecheck`)
   
   _Claude Code on behalf of gnodet_


-- 
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]

Reply via email to