This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new d2e763892641 fix(components): ftp resource leakage
d2e763892641 is described below
commit d2e7638926411aa3f666feeb94e8cd55c86ddc05
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Thu Nov 27 10:45:45 2025 +0100
fix(components): ftp resource leakage
Additionally fixing minor compilation warnings.
---
.../file/remote/DefaultFtpClientActivityListener.java | 3 +--
.../apache/camel/component/file/remote/FtpsEndpoint.java | 13 +++++++------
.../apache/camel/component/file/remote/SftpDevConsole.java | 1 -
.../file/remote/strategy/SftpProcessStrategyFactory.java | 1 -
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
index 5fd968e7bdd1..5e963c51b281 100644
---
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
@@ -22,11 +22,10 @@ import org.apache.camel.util.StopWatch;
import org.apache.camel.util.StringHelper;
import org.apache.camel.util.TimeUtils;
import org.apache.commons.net.io.CopyStreamEvent;
-import org.apache.commons.net.io.CopyStreamListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DefaultFtpClientActivityListener implements
FtpClientActivityListener, CopyStreamListener {
+public class DefaultFtpClientActivityListener implements
FtpClientActivityListener {
private static final Logger LOG =
LoggerFactory.getLogger(DefaultFtpClientActivityListener.class);
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
index b550e235417e..9523e2141a68 100644
---
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
@@ -107,12 +107,13 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
// already configured configuration
// from the socket for all future sockets it creates. Not sexy and
a
// little brittle, but it works.
- SSLSocket socket = (SSLSocket)
context.getSocketFactory().createSocket();
- client.setEnabledCipherSuites(socket.getEnabledCipherSuites());
- client.setEnabledProtocols(socket.getEnabledProtocols());
- client.setNeedClientAuth(socket.getNeedClientAuth());
- client.setWantClientAuth(socket.getWantClientAuth());
-
client.setEnabledSessionCreation(socket.getEnableSessionCreation());
+ try (SSLSocket socket = (SSLSocket)
context.getSocketFactory().createSocket()) {
+ client.setEnabledCipherSuites(socket.getEnabledCipherSuites());
+ client.setEnabledProtocols(socket.getEnabledProtocols());
+ client.setNeedClientAuth(socket.getNeedClientAuth());
+ client.setWantClientAuth(socket.getWantClientAuth());
+
client.setEnabledSessionCreation(socket.getEnableSessionCreation());
+ }
} else {
client = new
FTPSClient(getFtpsConfiguration().getSecurityProtocol(),
getFtpsConfiguration().isImplicit());
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
index 5f2cca61d65c..c1438636c293 100644
---
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
@@ -58,7 +58,6 @@ public class SftpDevConsole extends AbstractDevConsole {
JsonObject jo = new JsonObject();
for (var e : map.entrySet()) {
- String v = e.getValue() != null ? e.getValue().toString() : "";
jo.put(e.getKey(), e.getValue());
}
root.put("config", jo);
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
index 9363b1f25bf1..434c8a93e807 100644
---
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
@@ -90,7 +90,6 @@ public final class SftpProcessStrategyFactory implements
GenericFileProcessStrat
}
}
- @SuppressWarnings("unchecked")
private static GenericFileExclusiveReadLockStrategy
getExclusiveReadLockStrategy(Map<String, Object> params) {
GenericFileExclusiveReadLockStrategy strategy
= (GenericFileExclusiveReadLockStrategy)
params.get("exclusiveReadLockStrategy");