You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ap...@apache.org on 2026/03/05 12:07:05 UTC

(camel) branch main updated: Replace this instanceof check and cast directly in mina-sftp

This is an automated email from the ASF dual-hosted git repository.

apupier 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 3bcbbf059bae Replace this instanceof check and cast directly in mina-sftp
3bcbbf059bae is described below

commit 3bcbbf059bae1b8a313f159b5ab4cf879ac45c73
Author: Aurélien Pupier <ap...@ibm.com>
AuthorDate: Thu Mar 5 10:15:41 2026 +0100

    Replace this instanceof check and cast directly in mina-sftp
    
    Signed-off-by: Aurélien Pupier <ap...@ibm.com>
---
 .../component/file/remote/mina/MinaSftpServerKeyVerifier.java | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/components/camel-mina-sftp/src/main/java/org/apache/camel/component/file/remote/mina/MinaSftpServerKeyVerifier.java b/components/camel-mina-sftp/src/main/java/org/apache/camel/component/file/remote/mina/MinaSftpServerKeyVerifier.java
index e6574b110c00..7f214c5b50a7 100644
--- a/components/camel-mina-sftp/src/main/java/org/apache/camel/component/file/remote/mina/MinaSftpServerKeyVerifier.java
+++ b/components/camel-mina-sftp/src/main/java/org/apache/camel/component/file/remote/mina/MinaSftpServerKeyVerifier.java
@@ -227,8 +227,7 @@ public class MinaSftpServerKeyVerifier extends KnownHostsServerKeyVerifier {
 
         // If server presented a certificate, perform additional validation
         // that MINA SSHD doesn't do: type, validity, principals
-        if (serverKey instanceof OpenSshCertificate) {
-            OpenSshCertificate certificate = (OpenSshCertificate) serverKey;
+        if (serverKey instanceof OpenSshCertificate certificate) {
             String hostname = extractHostname(remoteAddress);
             int port = extractPort(remoteAddress);
 
@@ -363,15 +362,15 @@ public class MinaSftpServerKeyVerifier extends KnownHostsServerKeyVerifier {
     }
 
     private String extractHostname(SocketAddress remoteAddress) {
-        if (remoteAddress instanceof InetSocketAddress) {
-            return ((InetSocketAddress) remoteAddress).getHostString();
+        if (remoteAddress instanceof InetSocketAddress inetRemoteSocketAddress) {
+            return inetRemoteSocketAddress.getHostString();
         }
         return remoteAddress.toString();
     }
 
     private int extractPort(SocketAddress remoteAddress) {
-        if (remoteAddress instanceof InetSocketAddress) {
-            return ((InetSocketAddress) remoteAddress).getPort();
+        if (remoteAddress instanceof InetSocketAddress inetRemoteSocketAddress) {
+            return inetRemoteSocketAddress.getPort();
         }
         return 22;
     }