You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tw...@apache.org on 2022/10/30 20:58:12 UTC

[mina-sshd] branch master updated (de72f23cb -> b19a3ed0b)

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

twolf pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


    from de72f23cb Manual format fixes for column-aligned "+" operators
     new 4037290a0 Use ThreadLocal.remove() instead of ThreadLocal.set(null)
     new b19a3ed0b Fix some SonarLint findings

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sshd/cli/client/SshClientCliSupport.java       |  10 +-
 .../sshd/cli/server/SshServerCliSupport.java       |   3 +-
 .../server/helper/ServerEventListenerHelper.java   |   2 +-
 .../helper/ServerPortForwardingEventListener.java  |   6 +-
 .../auth/hostbased/HostKeyIdentityProvider.java    |   2 +-
 .../client/config/hosts/KnownHostHashValue.java    |   5 +-
 .../config/keys/ClientIdentitiesWatcher.java       |   2 +-
 .../config/keys/ClientIdentityFileWatcher.java     |   4 +-
 .../client/config/keys/ClientIdentityProvider.java |   6 +-
 .../config/keys/LazyClientIdentityIterator.java    |  23 ++-
 .../org/apache/sshd/common/channel/PtyMode.java    |  13 +-
 .../sshd/common/config/VersionProperties.java      |   4 +-
 .../apache/sshd/common/config/keys/KeyUtils.java   |   2 +-
 .../keys/impl/AbstractPublicKeyEntryDecoder.java   |   2 +-
 .../openssh/OpenSSHDSSPrivateKeyEntryDecoder.java  |  11 +-
 .../OpenSSHECDSAPrivateKeyEntryDecoder.java        |   7 +-
 .../openssh/OpenSSHRSAPrivateKeyDecoder.java       |  14 +-
 .../sshd/common/file/util/BaseFileSystem.java      |   2 +-
 .../org/apache/sshd/common/file/util/BasePath.java |   2 +-
 .../sshd/common/io/AbstractIoWriteFuture.java      |   8 +
 .../AbstractResourceKeyPairProvider.java           |   8 +-
 .../common/keyprovider/KeyIdentityProvider.java    |   2 +-
 .../common/keyprovider/MappedKeyPairProvider.java  |   4 +-
 .../java/org/apache/sshd/common/mac/BaseMac.java   |   2 +-
 .../sshd/common/signature/AbstractSignature.java   |   2 +-
 .../apache/sshd/common/signature/SignatureDSA.java |   2 +-
 .../apache/sshd/common/util/ExceptionUtils.java    |   5 +-
 .../org/apache/sshd/common/util/GenericUtils.java  |   6 +-
 .../org/apache/sshd/common/util/SelectorUtils.java |  14 --
 .../org/apache/sshd/common/util/ValidateUtils.java |  20 +--
 .../common/util/closeable/FuturesCloseable.java    |   4 +-
 .../common/util/closeable/ParallelCloseable.java   |   4 +-
 .../sshd/common/util/io/PathScanningMatcher.java   |   2 +-
 .../sshd/common/util/security/SecurityUtils.java   |   4 +-
 .../security/bouncycastle/BouncyCastleRandom.java  |   2 +-
 .../security/eddsa/EdDSASecurityProviderUtils.java |   8 +-
 .../util/security/eddsa/SignatureEd25519.java      |   2 +-
 .../sshd/common/util/threads/ThreadUtils.java      |  28 ++--
 .../AbstractGeneratorHostKeyProvider.java          |   8 +-
 .../keys/BuiltinClientIdentitiesWatcherTest.java   |   2 +-
 .../openssh/OpenSSHKeyPairResourceWriterTest.java  |   4 -
 .../sshd/util/test/CommonTestSupportUtils.java     |   4 +-
 .../throttle/ThrottlingChannelStreamWriter.java    |   2 +-
 .../contrib/common/signature/LegacyDSASigner.java  |   2 +-
 .../sshd/agent/common/AbstractAgentProxy.java      |   2 +-
 .../apache/sshd/agent/local/AgentServerProxy.java  |   6 +-
 .../org/apache/sshd/agent/unix/AgentServer.java    |   2 +-
 .../apache/sshd/agent/unix/AgentServerProxy.java   |   2 +-
 .../org/apache/sshd/agent/unix/AprLibrary.java     |   8 +-
 .../sshd/agent/unix/ChannelAgentForwarding.java    |   2 +-
 .../sshd/client/future/DefaultConnectFuture.java   |   2 +-
 .../sshd/common/channel/AbstractChannel.java       |  22 +--
 .../common/channel/BufferedIoOutputStream.java     |  16 +-
 .../common/channel/ChannelAsyncInputStream.java    |   4 +-
 .../sshd/common/forward/DefaultForwarder.java      | 173 +++++++--------------
 .../io/BuiltinIoServiceFactoryFactories.java       |   8 +-
 .../common/io/DefaultIoServiceFactoryFactory.java  |   3 +-
 .../apache/sshd/common/io/nio2/Nio2Service.java    |   6 +-
 .../sshd/common/kex/dh/AbstractDHKeyExchange.java  |   4 +-
 .../session/helpers/AbstractConnectionService.java |   6 +-
 .../common/session/helpers/AbstractSession.java    |  12 +-
 .../session/helpers/AbstractSessionIoHandler.java  |   6 +-
 .../session/helpers/KeyExchangeMessageHandler.java |   6 +-
 .../java/org/apache/sshd/server/SshServer.java     |   4 +-
 .../sshd/server/auth/AsyncAuthException.java       |   2 +-
 .../apache/sshd/server/auth/gss/UserAuthGSS.java   |   2 +-
 ...AuthorizedKeyEntriesPublickeyAuthenticator.java |   6 +-
 .../auth/pubkey/KeySetPublickeyAuthenticator.java  |   4 +-
 .../sshd/server/channel/PuttyRequestHandler.java   |   6 +-
 .../server/command/AbstractCommandSupport.java     |   6 +-
 .../server/command/AbstractFileSystemCommand.java  |   2 +-
 .../sshd/server/forward/DirectTcpipFactory.java    |   2 +-
 .../sshd/server/forward/ForwardedTcpipFactory.java |   2 +-
 .../forward/StaticDecisionForwardingFilter.java    |   2 +-
 .../sshd/server/forward/TcpipServerChannel.java    |  15 +-
 .../sshd/server/session/ServerUserAuthService.java |   6 +-
 .../channel/ChannelPipedInputStreamTest.java       |   2 +-
 .../org/apache/sshd/git/AbstractGitCommand.java    |   2 -
 .../org/apache/sshd/git/pack/GitPackCommand.java   |   4 +-
 .../org/apache/sshd/git/pgm/GitPgmCommand.java     |   1 -
 .../sshd/openpgp/PGPAuthorizedEntriesTracker.java  |   2 +-
 .../sshd/openpgp/PGPKeyPairResourceParser.java     |   3 -
 .../sshd/scp/client/AbstractScpClientCreator.java  |   2 +-
 .../java/org/apache/sshd/scp/common/ScpHelper.java |   4 +-
 .../helpers/LocalFileScpTargetStreamResolver.java  |  10 +-
 .../apache/sshd/scp/common/helpers/ScpIoUtils.java |  12 +-
 .../apache/sshd/scp/server/InputStreamReader.java  |  22 +--
 .../helpers/AbstractSftpClientExtension.java       |   2 +-
 .../sftp/client/fs/SftpClientDirectoryScanner.java |   2 +-
 .../apache/sshd/sftp/client/fs/SftpFileSystem.java |   2 +-
 .../sftp/client/fs/SftpFileSystemProvider.java     |   4 +-
 .../sftp/client/fs/SftpPathDirectoryScanner.java   |   2 +-
 .../sshd/sftp/client/impl/DefaultSftpClient.java   |   2 +-
 .../sftp/client/impl/SftpDirEntryIterator.java     |   2 +-
 .../sftp/client/impl/SftpInputStreamAsync.java     |   4 +-
 .../sftp/client/impl/SftpOutputStreamAsync.java    |   2 +-
 .../org/apache/sshd/sftp/common/SftpHelper.java    |   8 +-
 .../server/AbstractSftpEventListenerAdapter.java   |  76 ++++-----
 .../sftp/server/AbstractSftpSubsystemHelper.java   |  50 +++---
 .../org/apache/sshd/sftp/server/SftpSubsystem.java |  11 +-
 .../common/SftpUniversalOwnerAndGroupTest.java     |   2 +-
 .../integration/ApacheSshdSftpSessionFactory.java  |  37 ++---
 102 files changed, 351 insertions(+), 537 deletions(-)


[mina-sshd] 01/02: Use ThreadLocal.remove() instead of ThreadLocal.set(null)

Posted by tw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 4037290a0849abc65dececd66ac1a6bdc5ba1cd9
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Sun Oct 30 00:07:05 2022 +0200

    Use ThreadLocal.remove() instead of ThreadLocal.set(null)
    
    ThreadLocal.set(null) keeps a reference to the ThreadLocal instance in
    the thread, which can lead to (small) memory leaks when threads are
    re-used, for instance via thread pools.
---
 .../sshd/common/util/threads/ThreadUtils.java      | 26 +++++++++++++---------
 .../apache/sshd/sftp/client/fs/SftpFileSystem.java |  2 +-
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
index d06da9f69..b93e81ed5 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
@@ -60,12 +60,15 @@ public final class ThreadUtils {
      * @see              {@link #isInternal()}
      */
     public static <V> V runAsInternal(Callable<V> code) throws Exception {
-        Boolean initial = IS_INTERNAL_THREAD.get();
-        try {
-            IS_INTERNAL_THREAD.set(Boolean.TRUE);
+        if (isInternalThread()) {
             return code.call();
-        } finally {
-            IS_INTERNAL_THREAD.set(initial);
+        } else {
+            try {
+                IS_INTERNAL_THREAD.set(Boolean.TRUE);
+                return code.call();
+            } finally {
+                IS_INTERNAL_THREAD.remove();
+            }
         }
     }
 
@@ -82,12 +85,15 @@ public final class ThreadUtils {
      * @see              {@link #isInternal()}
      */
     public static <T, V> V runAsInternal(T param, IOFunction<? super T, V> code) throws IOException {
-        Boolean initial = IS_INTERNAL_THREAD.get();
-        try {
-            IS_INTERNAL_THREAD.set(Boolean.TRUE);
+        if (isInternalThread()) {
             return code.apply(param);
-        } finally {
-            IS_INTERNAL_THREAD.set(initial);
+        } else {
+            try {
+                IS_INTERNAL_THREAD.set(Boolean.TRUE);
+                return code.apply(param);
+            } finally {
+                IS_INTERNAL_THREAD.remove();
+            }
         }
     }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
index 47f999758..ae8049285 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
@@ -298,7 +298,7 @@ public class SftpFileSystem
                 if (!pool.offer(delegate)) {
                     delegate.close();
                 }
-                wrappers.set(null);
+                wrappers.remove();
             }
         }
 


[mina-sshd] 02/02: Fix some SonarLint findings

Posted by tw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit b19a3ed0bfe9b933463307278db5632ab2602b70
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Sun Oct 30 18:57:08 2022 +0100

    Fix some SonarLint findings
    
    Simple ones:
    
    - Logging statements: use placeholders, not string concatenation
    - Abstract classes: use protected, not public, constructors
    - Some simplified lambdas
    - Some simplified exception catching
    - Use StringBuilder instead of StringBuffer
    - Use BigInteger.valueOf() instead of new BigInteger()
    - Use "byte[] buf" instead of "byte buf[]"
    
    There are still a lot of more findings some of them worrying, such as
    throwing exceptions in finally blocks, or catching Error or Throwable
    in several places, or others.
---
 .../sshd/cli/client/SshClientCliSupport.java       |  10 +-
 .../sshd/cli/server/SshServerCliSupport.java       |   3 +-
 .../server/helper/ServerEventListenerHelper.java   |   2 +-
 .../helper/ServerPortForwardingEventListener.java  |   6 +-
 .../auth/hostbased/HostKeyIdentityProvider.java    |   2 +-
 .../client/config/hosts/KnownHostHashValue.java    |   5 +-
 .../config/keys/ClientIdentitiesWatcher.java       |   2 +-
 .../config/keys/ClientIdentityFileWatcher.java     |   4 +-
 .../client/config/keys/ClientIdentityProvider.java |   6 +-
 .../config/keys/LazyClientIdentityIterator.java    |  23 ++-
 .../org/apache/sshd/common/channel/PtyMode.java    |  13 +-
 .../sshd/common/config/VersionProperties.java      |   4 +-
 .../apache/sshd/common/config/keys/KeyUtils.java   |   2 +-
 .../keys/impl/AbstractPublicKeyEntryDecoder.java   |   2 +-
 .../openssh/OpenSSHDSSPrivateKeyEntryDecoder.java  |  11 +-
 .../OpenSSHECDSAPrivateKeyEntryDecoder.java        |   7 +-
 .../openssh/OpenSSHRSAPrivateKeyDecoder.java       |  14 +-
 .../sshd/common/file/util/BaseFileSystem.java      |   2 +-
 .../org/apache/sshd/common/file/util/BasePath.java |   2 +-
 .../sshd/common/io/AbstractIoWriteFuture.java      |   8 +
 .../AbstractResourceKeyPairProvider.java           |   8 +-
 .../common/keyprovider/KeyIdentityProvider.java    |   2 +-
 .../common/keyprovider/MappedKeyPairProvider.java  |   4 +-
 .../java/org/apache/sshd/common/mac/BaseMac.java   |   2 +-
 .../sshd/common/signature/AbstractSignature.java   |   2 +-
 .../apache/sshd/common/signature/SignatureDSA.java |   2 +-
 .../apache/sshd/common/util/ExceptionUtils.java    |   5 +-
 .../org/apache/sshd/common/util/GenericUtils.java  |   6 +-
 .../org/apache/sshd/common/util/SelectorUtils.java |  14 --
 .../org/apache/sshd/common/util/ValidateUtils.java |  20 +--
 .../common/util/closeable/FuturesCloseable.java    |   4 +-
 .../common/util/closeable/ParallelCloseable.java   |   4 +-
 .../sshd/common/util/io/PathScanningMatcher.java   |   2 +-
 .../sshd/common/util/security/SecurityUtils.java   |   4 +-
 .../security/bouncycastle/BouncyCastleRandom.java  |   2 +-
 .../security/eddsa/EdDSASecurityProviderUtils.java |   8 +-
 .../util/security/eddsa/SignatureEd25519.java      |   2 +-
 .../sshd/common/util/threads/ThreadUtils.java      |   2 +-
 .../AbstractGeneratorHostKeyProvider.java          |   8 +-
 .../keys/BuiltinClientIdentitiesWatcherTest.java   |   2 +-
 .../openssh/OpenSSHKeyPairResourceWriterTest.java  |   4 -
 .../sshd/util/test/CommonTestSupportUtils.java     |   4 +-
 .../throttle/ThrottlingChannelStreamWriter.java    |   2 +-
 .../contrib/common/signature/LegacyDSASigner.java  |   2 +-
 .../sshd/agent/common/AbstractAgentProxy.java      |   2 +-
 .../apache/sshd/agent/local/AgentServerProxy.java  |   6 +-
 .../org/apache/sshd/agent/unix/AgentServer.java    |   2 +-
 .../apache/sshd/agent/unix/AgentServerProxy.java   |   2 +-
 .../org/apache/sshd/agent/unix/AprLibrary.java     |   8 +-
 .../sshd/agent/unix/ChannelAgentForwarding.java    |   2 +-
 .../sshd/client/future/DefaultConnectFuture.java   |   2 +-
 .../sshd/common/channel/AbstractChannel.java       |  22 +--
 .../common/channel/BufferedIoOutputStream.java     |  16 +-
 .../common/channel/ChannelAsyncInputStream.java    |   4 +-
 .../sshd/common/forward/DefaultForwarder.java      | 173 +++++++--------------
 .../io/BuiltinIoServiceFactoryFactories.java       |   8 +-
 .../common/io/DefaultIoServiceFactoryFactory.java  |   3 +-
 .../apache/sshd/common/io/nio2/Nio2Service.java    |   6 +-
 .../sshd/common/kex/dh/AbstractDHKeyExchange.java  |   4 +-
 .../session/helpers/AbstractConnectionService.java |   6 +-
 .../common/session/helpers/AbstractSession.java    |  12 +-
 .../session/helpers/AbstractSessionIoHandler.java  |   6 +-
 .../session/helpers/KeyExchangeMessageHandler.java |   6 +-
 .../java/org/apache/sshd/server/SshServer.java     |   4 +-
 .../sshd/server/auth/AsyncAuthException.java       |   2 +-
 .../apache/sshd/server/auth/gss/UserAuthGSS.java   |   2 +-
 ...AuthorizedKeyEntriesPublickeyAuthenticator.java |   6 +-
 .../auth/pubkey/KeySetPublickeyAuthenticator.java  |   4 +-
 .../sshd/server/channel/PuttyRequestHandler.java   |   6 +-
 .../server/command/AbstractCommandSupport.java     |   6 +-
 .../server/command/AbstractFileSystemCommand.java  |   2 +-
 .../sshd/server/forward/DirectTcpipFactory.java    |   2 +-
 .../sshd/server/forward/ForwardedTcpipFactory.java |   2 +-
 .../forward/StaticDecisionForwardingFilter.java    |   2 +-
 .../sshd/server/forward/TcpipServerChannel.java    |  15 +-
 .../sshd/server/session/ServerUserAuthService.java |   6 +-
 .../channel/ChannelPipedInputStreamTest.java       |   2 +-
 .../org/apache/sshd/git/AbstractGitCommand.java    |   2 -
 .../org/apache/sshd/git/pack/GitPackCommand.java   |   4 +-
 .../org/apache/sshd/git/pgm/GitPgmCommand.java     |   1 -
 .../sshd/openpgp/PGPAuthorizedEntriesTracker.java  |   2 +-
 .../sshd/openpgp/PGPKeyPairResourceParser.java     |   3 -
 .../sshd/scp/client/AbstractScpClientCreator.java  |   2 +-
 .../java/org/apache/sshd/scp/common/ScpHelper.java |   4 +-
 .../helpers/LocalFileScpTargetStreamResolver.java  |  10 +-
 .../apache/sshd/scp/common/helpers/ScpIoUtils.java |  12 +-
 .../apache/sshd/scp/server/InputStreamReader.java  |  22 +--
 .../helpers/AbstractSftpClientExtension.java       |   2 +-
 .../sftp/client/fs/SftpClientDirectoryScanner.java |   2 +-
 .../sftp/client/fs/SftpFileSystemProvider.java     |   4 +-
 .../sftp/client/fs/SftpPathDirectoryScanner.java   |   2 +-
 .../sshd/sftp/client/impl/DefaultSftpClient.java   |   2 +-
 .../sftp/client/impl/SftpDirEntryIterator.java     |   2 +-
 .../sftp/client/impl/SftpInputStreamAsync.java     |   4 +-
 .../sftp/client/impl/SftpOutputStreamAsync.java    |   2 +-
 .../org/apache/sshd/sftp/common/SftpHelper.java    |   8 +-
 .../server/AbstractSftpEventListenerAdapter.java   |  76 ++++-----
 .../sftp/server/AbstractSftpSubsystemHelper.java   |  50 +++---
 .../org/apache/sshd/sftp/server/SftpSubsystem.java |  11 +-
 .../common/SftpUniversalOwnerAndGroupTest.java     |   2 +-
 .../integration/ApacheSshdSftpSessionFactory.java  |  37 ++---
 101 files changed, 334 insertions(+), 526 deletions(-)

diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
index 82f87d8c4..204e70743 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
@@ -695,10 +695,10 @@ public abstract class SshClientCliSupport extends CliSupport {
         fh.setLevel(Level.FINEST);
         fh.setFormatter(new Formatter() {
             @Override
-            public String format(LogRecord record) {
-                String message = formatMessage(record);
+            public String format(LogRecord logRecord) {
+                String message = formatMessage(logRecord);
                 String throwable = "";
-                Throwable t = record.getThrown();
+                Throwable t = logRecord.getThrown();
                 if (t != null) {
                     StringWriter sw = new StringWriter();
                     try (PrintWriter pw = new PrintWriter(sw)) {
@@ -708,8 +708,8 @@ public abstract class SshClientCliSupport extends CliSupport {
                     throwable = sw.toString();
                 }
                 return String.format("%1$tY-%1$tm-%1$td: %2$-7.7s: %3$-32.32s: %4$s%5$s%n",
-                        new Date(record.getMillis()), record.getLevel().getName(),
-                        record.getLoggerName(), message, throwable);
+                        new Date(logRecord.getMillis()), logRecord.getLevel().getName(),
+                        logRecord.getLoggerName(), message, throwable);
             }
         });
 
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
index d5ec09c33..cbd01e013 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
@@ -225,8 +225,7 @@ public abstract class SshServerCliSupport extends CliSupport {
                 continue;
             }
 
-            factory = registerSubsystemFactoryListeners(
-                    server, level, stdout, stderr, options, factory);
+            registerSubsystemFactoryListeners(server, level, stdout, stderr, options, factory);
             subsystems.add(factory);
         }
 
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
index b79bccdff..264bb2b9b 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
@@ -26,7 +26,7 @@ import org.slf4j.Logger;
 public abstract class ServerEventListenerHelper extends AbstractLoggingBean implements NamedResource {
     private final String name;
 
-    public ServerEventListenerHelper(String name, Logger logger) {
+    protected ServerEventListenerHelper(String name, Logger logger) {
         super(logger);
 
         this.name = name;
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
index cdcd97617..78f5045b3 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
@@ -72,10 +72,10 @@ public class ServerPortForwardingEventListener extends ServerEventListenerHelper
             throws IOException {
         if (reason == null) {
             if (log.isInfoEnabled()) {
-                log.info("Estalibshed dynamic tunnel for session={}: local={},  bound={}", session, local, boundAddress);
+                log.info("Estalibshed dynamic tunnel for session={}: local={} bound={}", session, local, boundAddress);
             }
         } else {
-            log.error("Failed ({}) to establish dynamic tunnel for session={}, bound={}: {}",
+            log.error("Failed ({}) to establish dynamic tunnel for session={}: local={} bound={}: {}",
                     reason.getClass().getSimpleName(), session, local, boundAddress, reason.getMessage());
         }
     }
@@ -86,7 +86,7 @@ public class ServerPortForwardingEventListener extends ServerEventListenerHelper
             throws IOException {
         if (reason == null) {
             if (log.isInfoEnabled()) {
-                log.info("Torn down dynamic tunnel for session={}: address={}", session);
+                log.info("Torn down dynamic tunnel for session={}: address={}", session, address);
             }
         } else {
             log.error("Failed ({}) to tear down dynamic tunnel for session={}, address={}: {}",
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
index f08a7b7eb..02b1c3fec 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
@@ -58,7 +58,7 @@ public interface HostKeyIdentityProvider {
         return wrap(GenericUtils.asList(pairs));
     }
 
-    static HostKeyIdentityProvider wrap(Iterable<? extends KeyPair> pairs) {
+    static HostKeyIdentityProvider wrap(Iterable<KeyPair> pairs) {
         return session -> GenericUtils.wrapIterable(pairs,
                 kp -> new SimpleImmutableEntry<>(kp, Collections.<X509Certificate> emptyList()));
     }
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
index 4831541f2..2e6bb7436 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
@@ -96,10 +96,9 @@ public class KnownHostHashValue {
             byte[] expected = getDigestValue();
             byte[] actual = calculateHashValue(host, port, getDigester(), getSaltValue());
             return Arrays.equals(expected, actual);
+        } catch (RuntimeException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            }
             throw new RuntimeSshException(
                     "Failed (" + t.getClass().getSimpleName() + ")" + " to calculate hash value: " + t.getMessage(), t);
         }
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
index ea21386ca..75c587a16 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
@@ -74,7 +74,7 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements
         return loadKeys(session, null);
     }
 
-    protected Iterable<KeyPair> loadKeys(SessionContext session, Predicate<? super KeyPair> filter) {
+    protected Iterable<KeyPair> loadKeys(SessionContext session, Predicate<KeyPair> filter) {
         return ClientIdentityProvider.lazyKeysLoader(providers, p -> doGetKeyPairs(session, p), filter);
     }
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
index 7324362eb..784ce2bd3 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
@@ -94,13 +94,13 @@ public class ClientIdentityFileWatcher
             return identitiesHolder.get();
         }
 
-        Iterable<KeyPair> kp = identitiesHolder.getAndSet(null); // start fresh
+        identitiesHolder.set(null); // start fresh
         Path path = getPath();
         if (!exists()) {
             return identitiesHolder.get();
         }
 
-        kp = reloadClientIdentities(session, path);
+        Iterable<KeyPair> kp = reloadClientIdentities(session, path);
         updateReloadAttributes();
         identitiesHolder.set(kp);
         return kp;
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
index 1a8fe6128..51a5ce207 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
@@ -79,8 +79,7 @@ public interface ClientIdentityProvider {
      */
     static Iterable<KeyPair> lazyKeysLoader(
             Iterable<? extends ClientIdentityProvider> providers,
-            Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor,
-            Predicate<? super KeyPair> filter) {
+            Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> kpExtractor, Predicate<KeyPair> filter) {
         Objects.requireNonNull(kpExtractor, "No key pair extractor provided");
         if (providers == null) {
             return Collections.emptyList();
@@ -114,8 +113,7 @@ public interface ClientIdentityProvider {
      */
     static Iterator<KeyPair> lazyKeysIterator(
             Iterator<? extends ClientIdentityProvider> providers,
-            Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor,
-            Predicate<? super KeyPair> filter) {
+            Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> kpExtractor, Predicate<KeyPair> filter) {
         Objects.requireNonNull(kpExtractor, "No key pair extractor provided");
         return (providers == null)
                 ? Collections.emptyIterator()
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
index aaa19e2e3..df0e8fe90 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
@@ -37,12 +37,12 @@ import org.apache.sshd.common.keyprovider.KeyIdentityProvider;
  */
 public class LazyClientIdentityIterator implements Iterator<KeyPair> {
     protected boolean finished;
-    protected Iterator<? extends KeyPair> currentIdentities;
+    protected Iterator<KeyPair> currentIdentities;
     protected KeyPair currentPair;
 
     private final Iterator<? extends ClientIdentityProvider> providers;
-    private final Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor;
-    private final Predicate<? super KeyPair> filter;
+    private final Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> kpExtractor;
+    private final Predicate<KeyPair> filter;
 
     /**
      * @param providers   The providers - ignored if {@code null}
@@ -52,10 +52,9 @@ public class LazyClientIdentityIterator implements Iterator<KeyPair> {
      * @param filter      Any further filter to apply on (non-{@code null}) key pairs before returning it as the
      *                    {@link Iterator#next()} result.
      */
-    public LazyClientIdentityIterator(
-                                      Iterator<? extends ClientIdentityProvider> providers,
-                                      Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor,
-                                      Predicate<? super KeyPair> filter) {
+    public LazyClientIdentityIterator(Iterator<? extends ClientIdentityProvider> providers,
+                                      Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> kpExtractor,
+                                      Predicate<KeyPair> filter) {
         this.providers = providers;
         this.kpExtractor = Objects.requireNonNull(kpExtractor, "No key pair extractor provided");
         this.filter = filter;
@@ -65,11 +64,11 @@ public class LazyClientIdentityIterator implements Iterator<KeyPair> {
         return providers;
     }
 
-    public Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> getIdentitiesExtractor() {
+    public Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> getIdentitiesExtractor() {
         return kpExtractor;
     }
 
-    public Predicate<? super KeyPair> getFilter() {
+    public Predicate<KeyPair> getFilter() {
         return filter;
     }
 
@@ -90,15 +89,15 @@ public class LazyClientIdentityIterator implements Iterator<KeyPair> {
             return true;
         }
 
-        Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> x = getIdentitiesExtractor();
-        Predicate<? super KeyPair> f = getFilter();
+        Function<? super ClientIdentityProvider, ? extends Iterable<KeyPair>> x = getIdentitiesExtractor();
+        Predicate<KeyPair> f = getFilter();
         while (provs.hasNext()) {
             ClientIdentityProvider p = provs.next();
             if (p == null) {
                 continue;
             }
 
-            Iterable<? extends KeyPair> ids = x.apply(p);
+            Iterable<KeyPair> ids = x.apply(p);
             currentIdentities = (ids == null) ? null : ids.iterator();
             currentPair = KeyIdentityProvider.exhaustCurrentIdentities(currentIdentities);
             if (currentPair == null) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
index 0f0a1a244..17335834d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
@@ -301,20 +301,17 @@ public enum PtyMode {
      * A {@code null}-safe {@link ToIntFunction} that returns the {@link PtyMode#toInt()} value and (-1) for
      * {@code null}
      */
-    public static final ToIntFunction<PtyMode> OPCODE_EXTRACTOR = v -> (v == null) ? -1 : v.toInt();
+    public static final ToIntFunction<PtyMode> OPCODE_EXTRACTOR = op -> (op == null) ? -1 : op.toInt();
 
     /**
      * A {@code null}-safe {@link Comparator} of {@link PtyMode} values according to their {@link PtyMode#toInt()} value
      *
      * @see #OPCODE_EXTRACTOR
      */
-    public static final Comparator<PtyMode> BY_OPCODE = new Comparator<PtyMode>() {
-        @Override
-        public int compare(PtyMode o1, PtyMode o2) {
-            int v1 = OPCODE_EXTRACTOR.applyAsInt(o1);
-            int v2 = OPCODE_EXTRACTOR.applyAsInt(o2);
-            return Integer.compare(v1, v2);
-        }
+    public static final Comparator<PtyMode> BY_OPCODE = (o1, o2) -> {
+        int v1 = OPCODE_EXTRACTOR.applyAsInt(o1);
+        int v2 = OPCODE_EXTRACTOR.applyAsInt(o2);
+        return Integer.compare(v1, v2);
     };
 
     private final int v;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
index 916057f83..296e70d74 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
@@ -69,7 +69,7 @@ public final class VersionProperties {
                     log.warn("Failed ({}) to load version properties from {}: {}",
                             e.getClass().getSimpleName(), cl, e.getMessage());
                     if (log.isDebugEnabled()) {
-                        log.debug("Version property failure details for loader=" + cl, e);
+                        log.debug("Version property failure details for loader={}", cl, e);
                     }
                     continue;
                 }
@@ -85,7 +85,7 @@ public final class VersionProperties {
                     String prev = result.put(key, value);
                     if (prev != null) {
                         Logger log = LoggerFactory.getLogger(anchor);
-                        log.warn("Multiple values for key=" + key + ": current=" + value + ", previous=" + prev);
+                        log.warn("Multiple values for key={}: current={}, previous={}", key, value, prev);
                     }
                 }
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
index e9ad39e41..ac8bf3f1f 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
@@ -103,7 +103,7 @@ public final class KeyUtils {
     /**
      * The most commonly used RSA public key exponent
      */
-    public static final BigInteger DEFAULT_RSA_PUBLIC_EXPONENT = new BigInteger("65537");
+    public static final BigInteger DEFAULT_RSA_PUBLIC_EXPONENT = BigInteger.valueOf(65537);
 
     /**
      * Name of algorithm for DSS keys to be used when calling security provider
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/AbstractPublicKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/AbstractPublicKeyEntryDecoder.java
index f0ebec6dd..71bbe8b3e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/AbstractPublicKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/AbstractPublicKeyEntryDecoder.java
@@ -51,7 +51,7 @@ public abstract class AbstractPublicKeyEntryDecoder<PUB extends PublicKey, PRV e
         try {
             boolVal = PropertyResolverUtils.parseBoolean(stringVal);
         } catch (IllegalArgumentException e) {
-            log.warn("Ignoring non-boolean property value for \"" + propertyKey + "\": " + stringVal);
+            log.warn("Ignoring non-boolean property value for \"{}\": {}", propertyKey, stringVal);
             boolVal = null;
         }
         if (boolVal == null) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHDSSPrivateKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHDSSPrivateKeyEntryDecoder.java
index 074a52236..32d4c3d58 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHDSSPrivateKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHDSSPrivateKeyEntryDecoder.java
@@ -70,16 +70,7 @@ public class OpenSSHDSSPrivateKeyEntryDecoder extends AbstractPrivateKeyEntryDec
         Objects.requireNonNull(y, "No public key data"); // TODO run some validation on it
         BigInteger x = KeyEntryResolver.decodeBigInt(keyData);
 
-        try {
-            return generatePrivateKey(new DSAPrivateKeySpec(x, p, q, g));
-        } finally {
-            // get rid of sensitive data a.s.a.p
-            p = null;
-            q = null;
-            g = null;
-            y = null;
-            x = null;
-        }
+        return generatePrivateKey(new DSAPrivateKeySpec(x, p, q, g));
     }
 
     @Override
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHECDSAPrivateKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHECDSAPrivateKeyEntryDecoder.java
index 3535fe76f..0a5669695 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHECDSAPrivateKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHECDSAPrivateKeyEntryDecoder.java
@@ -81,12 +81,7 @@ public class OpenSSHECDSAPrivateKeyEntryDecoder extends AbstractPrivateKeyEntryD
         Objects.requireNonNull(pubKey, "No public point"); // TODO validate it is a valid ECPoint
         BigInteger s = KeyEntryResolver.decodeBigInt(keyData);
         ECParameterSpec params = curve.getParameters();
-        try {
-            return generatePrivateKey(new ECPrivateKeySpec(s, params));
-        } finally {
-            // get rid of sensitive data a.s.a.p
-            s = null;
-        }
+        return generatePrivateKey(new ECPrivateKeySpec(s, params));
     }
 
     @Override
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHRSAPrivateKeyDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHRSAPrivateKeyDecoder.java
index 1df1d52fb..34ff03e71 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHRSAPrivateKeyDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHRSAPrivateKeyDecoder.java
@@ -48,7 +48,7 @@ import org.apache.sshd.common.util.security.SecurityUtils;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class OpenSSHRSAPrivateKeyDecoder extends AbstractPrivateKeyEntryDecoder<RSAPublicKey, RSAPrivateKey> {
-    public static final BigInteger DEFAULT_PUBLIC_EXPONENT = new BigInteger("65537");
+    public static final BigInteger DEFAULT_PUBLIC_EXPONENT = KeyUtils.DEFAULT_RSA_PUBLIC_EXPONENT;
     public static final OpenSSHRSAPrivateKeyDecoder INSTANCE = new OpenSSHRSAPrivateKeyDecoder();
 
     public OpenSSHRSAPrivateKeyDecoder() {
@@ -79,16 +79,8 @@ public class OpenSSHRSAPrivateKeyDecoder extends AbstractPrivateKeyEntryDecoder<
         if (!Objects.equals(n, modulus)) {
             log.warn("decodePrivateKey({}) mismatched modulus values: encoded={}, calculated={}", keyType, n, modulus);
         }
-        try {
-            return generatePrivateKey(new RSAPrivateCrtKeySpec(
-                    n, e, d, p, q, d.mod(p.subtract(BigInteger.ONE)), d.mod(q.subtract(BigInteger.ONE)), inverseQmodP));
-        } finally {
-            // get rid of sensitive data a.s.a.p
-            d = null;
-            inverseQmodP = null;
-            p = null;
-            q = null;
-        }
+        return generatePrivateKey(new RSAPrivateCrtKeySpec(n, e, d, p, q, d.mod(p.subtract(BigInteger.ONE)),
+                d.mod(q.subtract(BigInteger.ONE)), inverseQmodP));
     }
 
     @Override
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
index 08e2332c3..a5d099e8c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
@@ -41,7 +41,7 @@ public abstract class BaseFileSystem<T extends Path> extends FileSystem {
     protected final Logger log;
     private final FileSystemProvider fileSystemProvider;
 
-    public BaseFileSystem(FileSystemProvider fileSystemProvider) {
+    protected BaseFileSystem(FileSystemProvider fileSystemProvider) {
         this.log = LoggerFactory.getLogger(getClass());
         this.fileSystemProvider = Objects.requireNonNull(fileSystemProvider, "No file system provider");
     }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
index 021ffcd45..9fe527172 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
@@ -47,7 +47,7 @@ public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSys
     private String strValue;
     private int hashValue;
 
-    public BasePath(FS fileSystem, String root, List<String> names) {
+    protected BasePath(FS fileSystem, String root, List<String> names) {
         this.fileSystem = Objects.requireNonNull(fileSystem, "No file system provided");
         this.root = root;
         this.names = names;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java b/sshd-common/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
index efd090348..764cfa704 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
@@ -20,6 +20,7 @@
 package org.apache.sshd.common.io;
 
 import java.io.IOException;
+import java.util.Objects;
 
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
@@ -62,4 +63,11 @@ public abstract class AbstractIoWriteFuture
             return null;
         }
     }
+
+    public static IoWriteFuture fulfilled(Object id, Object value) {
+        AbstractIoWriteFuture result = new AbstractIoWriteFuture(id, null) {
+        };
+        result.setValue(Objects.requireNonNull(value));
+        return result;
+    }
 }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/AbstractResourceKeyPairProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/AbstractResourceKeyPairProvider.java
index 22f17bc6b..09c863b89 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/AbstractResourceKeyPairProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/AbstractResourceKeyPairProvider.java
@@ -105,7 +105,7 @@ public abstract class AbstractResourceKeyPairProvider<R> extends AbstractKeyPair
         }
 
         if (log.isDebugEnabled()) {
-            log.debug("resetCacheMap(" + resources + ") removed previous cached keys for " + toDelete);
+            log.debug("resetCacheMap({}) removed previous cached keys for {}", resources, toDelete);
         }
     }
 
@@ -208,10 +208,8 @@ public abstract class AbstractResourceKeyPairProvider<R> extends AbstractKeyPair
 
         @Override
         public KeyPair next() {
-            if (!nextKeyPairSet) {
-                if (!setNextObject()) {
-                    throw new NoSuchElementException("Out of files to try");
-                }
+            if (!nextKeyPairSet && !setNextObject()) {
+                throw new NoSuchElementException("Out of files to try");
             }
             nextKeyPairSet = false;
             return nextKeyPair;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
index 4e94416ce..4fa3cefa4 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
@@ -192,7 +192,7 @@ public interface KeyIdentityProvider {
      * @return     The first non-{@code null} key pair found in the iterator - {@code null} if all elements exhausted
      *             without such an entry
      */
-    static KeyPair exhaustCurrentIdentities(Iterator<? extends KeyPair> ids) {
+    static KeyPair exhaustCurrentIdentities(Iterator<KeyPair> ids) {
         while ((ids != null) && ids.hasNext()) {
             KeyPair kp = ids.next();
             if (kp != null) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MappedKeyPairProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MappedKeyPairProvider.java
index 8b58c2157..578576bbd 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MappedKeyPairProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MappedKeyPairProvider.java
@@ -51,7 +51,7 @@ public class MappedKeyPairProvider implements KeyPairProvider {
         this(GenericUtils.isEmpty(pairs) ? Collections.emptyList() : Arrays.asList(pairs));
     }
 
-    public MappedKeyPairProvider(Collection<? extends KeyPair> pairs) {
+    public MappedKeyPairProvider(Collection<KeyPair> pairs) {
         this(mapUniquePairs(pairs));
     }
 
@@ -79,7 +79,7 @@ public class MappedKeyPairProvider implements KeyPairProvider {
         return String.valueOf(pairsMap.keySet());
     }
 
-    public static Map<String, KeyPair> mapUniquePairs(Collection<? extends KeyPair> pairs) {
+    public static Map<String, KeyPair> mapUniquePairs(Collection<KeyPair> pairs) {
         if (GenericUtils.isEmpty(pairs)) {
             return Collections.emptyMap();
         }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/mac/BaseMac.java b/sshd-common/src/main/java/org/apache/sshd/common/mac/BaseMac.java
index 036d46f17..409d7b500 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/mac/BaseMac.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/mac/BaseMac.java
@@ -88,7 +88,7 @@ public class BaseMac implements Mac {
     }
 
     @Override
-    public void update(byte buf[], int offset, int len) {
+    public void update(byte[] buf, int offset, int len) {
         mac.update(buf, offset, len);
     }
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java
index d1677881c..c687dd723 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java
@@ -119,7 +119,7 @@ public abstract class AbstractSignature implements Signature {
      *                       data - {@code null} if not encoded
      */
     protected Map.Entry<String, byte[]> extractEncodedSignature(byte[] sig, Collection<String> expectedTypes) {
-        return GenericUtils.isEmpty(expectedTypes) ? null : extractEncodedSignature(sig, k -> expectedTypes.contains(k));
+        return GenericUtils.isEmpty(expectedTypes) ? null : extractEncodedSignature(sig, expectedTypes::contains);
     }
 
     protected Map.Entry<String, byte[]> extractEncodedSignature(byte[] sig, Predicate<? super String> typeSelector) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
index cc48088a4..b5620be43 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
@@ -101,7 +101,7 @@ public class SignatureDSA extends AbstractSignature {
 
         if (sigLen != DSA_SIGNATURE_LENGTH) {
             // probably some encoded data
-            Map.Entry<String, byte[]> encoding = extractEncodedSignature(sig, k -> KeyPairProvider.SSH_DSS.equalsIgnoreCase(k));
+            Map.Entry<String, byte[]> encoding = extractEncodedSignature(sig, KeyPairProvider.SSH_DSS::equalsIgnoreCase);
             if (encoding != null) {
                 String keyType = encoding.getKey();
                 ValidateUtils.checkTrue(
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/ExceptionUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/ExceptionUtils.java
index 64aae6821..7a1158dcf 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/ExceptionUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/ExceptionUtils.java
@@ -123,10 +123,7 @@ public final class ExceptionUtils {
                 return peelException(target);
             }
         } else if (t instanceof ExecutionException) {
-            Throwable wrapped = resolveExceptionCause(t);
-            if (wrapped != null) {
-                return peelException(wrapped);
-            }
+            return peelException(resolveExceptionCause(t));
         } else if (t instanceof MBeanException) {
             Throwable target = ((MBeanException) t).getTargetException();
             if (target != null) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/GenericUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/GenericUtils.java
index 445bcbe17..8ca104790 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/GenericUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/GenericUtils.java
@@ -780,13 +780,13 @@ public final class GenericUtils {
             return null;
         } else if (it instanceof Deque<?>) { // check before (!) instanceof List since LinkedList implements List
             Deque<? extends T> l = (Deque<? extends T>) it;
-            return (l.size() > 0) ? l.getFirst() : null;
+            return !l.isEmpty() ? l.getFirst() : null;
         } else if (it instanceof List<?>) {
             List<? extends T> l = (List<? extends T>) it;
-            return (l.size() > 0) ? l.get(0) : null;
+            return !l.isEmpty() ? l.get(0) : null;
         } else if (it instanceof SortedSet<?>) {
             SortedSet<? extends T> s = (SortedSet<? extends T>) it;
-            return (s.size() > 0) ? s.first() : null;
+            return !s.isEmpty() ? s.first() : null;
         } else {
             Iterator<? extends T> iter = it.iterator();
             return ((iter == null) || (!iter.hasNext())) ? null : iter.next();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/SelectorUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
index 3bf04fdcd..b400b7b40 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
@@ -235,8 +235,6 @@ public final class SelectorUtils {
 
             String subDir = strDirs.get(strIdxStart);
             if (!match(patDir, subDir, isCaseSensitive)) {
-                patDirs = null;
-                strDirs = null;
                 return false;
             }
 
@@ -249,8 +247,6 @@ public final class SelectorUtils {
             for (int i = patIdxStart; i <= patIdxEnd; i++) {
                 String subPat = patDirs.get(i);
                 if (!subPat.equals("**")) {
-                    patDirs = null;
-                    strDirs = null;
                     return false;
                 }
             }
@@ -258,8 +254,6 @@ public final class SelectorUtils {
         } else {
             if (patIdxStart > patIdxEnd) {
                 // String not exhausted, but pattern is. Failure.
-                patDirs = null;
-                strDirs = null;
                 return false;
             }
         }
@@ -273,8 +267,6 @@ public final class SelectorUtils {
 
             String subDir = strDirs.get(strIdxEnd);
             if (!match(patDir, subDir, isCaseSensitive)) {
-                patDirs = null;
-                strDirs = null;
                 return false;
             }
 
@@ -287,8 +279,6 @@ public final class SelectorUtils {
             for (int i = patIdxStart; i <= patIdxEnd; i++) {
                 String subPat = patDirs.get(i);
                 if (!subPat.equals("**")) {
-                    patDirs = null;
-                    strDirs = null;
                     return false;
                 }
             }
@@ -328,8 +318,6 @@ public final class SelectorUtils {
             }
 
             if (foundIdx == -1) {
-                patDirs = null;
-                strDirs = null;
                 return false;
             }
 
@@ -340,8 +328,6 @@ public final class SelectorUtils {
         for (int i = patIdxStart; i <= patIdxEnd; i++) {
             String subPat = patDirs.get(i);
             if (!subPat.equals("**")) {
-                patDirs = null;
-                strDirs = null;
                 return false;
             }
         }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/ValidateUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/ValidateUtils.java
index 5b3cb3899..7fcde1cc4 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/ValidateUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/ValidateUtils.java
@@ -70,61 +70,61 @@ public final class ValidateUtils {
     }
 
     public static <K, V, M extends Map<K, V>> M checkNotNullAndNotEmpty(M t, String message, Object... args) {
-        t = checkNotNull(t, message, args);
+        checkNotNull(t, message, args);
         checkTrue(MapEntryUtils.size(t) > 0, message, args);
         return t;
     }
 
     public static <T, C extends Collection<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) {
-        t = checkNotNull(t, message, args);
+        checkNotNull(t, message, args);
         checkTrue(GenericUtils.size(t) > 0, message, args);
         return t;
     }
 
     public static <T, C extends Iterable<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) {
-        t = checkNotNull(t, message, args);
+        checkNotNull(t, message, args);
         checkTrue(GenericUtils.isNotEmpty(t), message, args);
         return t;
     }
 
     public static byte[] checkNotNullAndNotEmpty(byte[] a, String message) {
-        a = checkNotNull(a, message);
+        checkNotNull(a, message);
         checkTrue(NumberUtils.length(a) > 0, message);
         return a;
     }
 
     public static byte[] checkNotNullAndNotEmpty(byte[] a, String message, Object... args) {
-        a = checkNotNull(a, message, args);
+        checkNotNull(a, message, args);
         checkTrue(NumberUtils.length(a) > 0, message, args);
         return a;
     }
 
     public static char[] checkNotNullAndNotEmpty(char[] a, String message) {
-        a = checkNotNull(a, message);
+        checkNotNull(a, message);
         checkTrue(GenericUtils.length(a) > 0, message);
         return a;
     }
 
     public static char[] checkNotNullAndNotEmpty(char[] a, String message, Object... args) {
-        a = checkNotNull(a, message, args);
+        checkNotNull(a, message, args);
         checkTrue(GenericUtils.length(a) > 0, message, args);
         return a;
     }
 
     public static int[] checkNotNullAndNotEmpty(int[] a, String message) {
-        a = checkNotNull(a, message);
+        checkNotNull(a, message);
         checkTrue(NumberUtils.length(a) > 0, message);
         return a;
     }
 
     public static int[] checkNotNullAndNotEmpty(int[] a, String message, Object... args) {
-        a = checkNotNull(a, message, args);
+        checkNotNull(a, message, args);
         checkTrue(NumberUtils.length(a) > 0, message, args);
         return a;
     }
 
     public static <T> T[] checkNotNullAndNotEmpty(T[] t, String message, Object... args) {
-        t = checkNotNull(t, message, args);
+        checkNotNull(t, message, args);
         checkTrue(GenericUtils.length(t) > 0, message, args);
         return t;
     }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java b/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
index 202db611f..dd09e7e69 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
@@ -54,7 +54,7 @@ public class FuturesCloseable<T extends SshFuture> extends SimpleCloseable {
             SshFutureListener<T> listener = f -> {
                 int pendingCount = count.decrementAndGet();
                 if (traceEnabled) {
-                    log.trace("doClose(" + immediately + ") complete pending: " + pendingCount);
+                    log.trace("doClose({}) complete pending: {}", immediately, pendingCount);
                 }
                 if (pendingCount == 0) {
                     future.setClosed();
@@ -65,7 +65,7 @@ public class FuturesCloseable<T extends SshFuture> extends SimpleCloseable {
                 if (f != null) {
                     int pendingCount = count.incrementAndGet();
                     if (traceEnabled) {
-                        log.trace("doClose(" + immediately + ") future pending: " + pendingCount);
+                        log.trace("doClose({}) future pending: {}", immediately, pendingCount);
                     }
                     f.addListener(listener);
                 }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java b/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
index 127ea662a..67a142c9e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
@@ -46,7 +46,7 @@ public class ParallelCloseable extends SimpleCloseable {
         SshFutureListener<CloseFuture> listener = f -> {
             int pendingCount = count.decrementAndGet();
             if (traceEnabled) {
-                log.trace("doClose(" + immediately + ") completed pending: " + pendingCount);
+                log.trace("doClose({}) completed pending: {}", immediately, pendingCount);
             }
             if (pendingCount == 0) {
                 future.setClosed();
@@ -60,7 +60,7 @@ public class ParallelCloseable extends SimpleCloseable {
 
             int pendingCount = count.incrementAndGet();
             if (traceEnabled) {
-                log.trace("doClose(" + immediately + ") pending closeables: " + pendingCount);
+                log.trace("doClose({}) pending closeables: {}", immediately, pendingCount);
             }
             c.close(immediately).addListener(listener);
         }
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/PathScanningMatcher.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/PathScanningMatcher.java
index 9dcaba473..e828daed6 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/PathScanningMatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/PathScanningMatcher.java
@@ -84,7 +84,7 @@ public abstract class PathScanningMatcher {
                 ? Collections.emptyList()
                 : Collections.unmodifiableList(
                         includes.stream()
-                                .map(v -> normalizePattern(v))
+                                .map(PathScanningMatcher::normalizePattern)
                                 .collect(Collectors.toCollection(() -> new ArrayList<>(includes.size()))));
     }
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java
index 7acb34fb7..22fdada54 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java
@@ -243,7 +243,7 @@ public final class SecurityUtils {
                 }
             } else {
                 Logger logger = LoggerFactory.getLogger(SecurityUtils.class);
-                logger.info("Override ECC support value: " + propValue);
+                logger.info("Override ECC support value: {}", propValue);
                 hasEcc = Boolean.valueOf(propValue);
             }
         }
@@ -349,7 +349,7 @@ public final class SecurityUtils {
         ValidateUtils.checkTrue(maxKeySize > Byte.SIZE, "Invalid max. key size: %d", maxKeySize);
 
         try {
-            BigInteger r = new BigInteger("0").setBit(maxKeySize - 1);
+            BigInteger r = BigInteger.ZERO.setBit(maxKeySize - 1);
             DHParameterSpec dhSkipParamSpec = new DHParameterSpec(r, r);
             KeyPairGenerator kpg = getKeyPairGenerator("DH");
             kpg.initialize(dhSkipParamSpec);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleRandom.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleRandom.java
index 3e44243ec..12c981156 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleRandom.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleRandom.java
@@ -74,7 +74,7 @@ public final class BouncyCastleRandom extends AbstractRandom {
 
     private int next(int numBits) {
         int bytes = (numBits + 7) / 8;
-        byte next[] = new byte[bytes];
+        byte[] next = new byte[bytes];
         int ret = 0;
         random.nextBytes(next);
         for (int i = 0; i < bytes; i++) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderUtils.java
index a142196e4..058472cfd 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderUtils.java
@@ -76,10 +76,8 @@ public final class EdDSASecurityProviderUtils {
         }
 
         if ((k1 instanceof EdDSAPublicKey) && (k2 instanceof EdDSAPublicKey)) {
-            if (Objects.equals(k1, k2)) {
+            if (k1.equals(k2)) {
                 return true;
-            } else if (k1 == null || k2 == null) {
-                return false; // both null is covered by Objects#equals
             }
 
             EdDSAPublicKey ed1 = (EdDSAPublicKey) k1;
@@ -136,10 +134,8 @@ public final class EdDSASecurityProviderUtils {
         }
 
         if ((k1 instanceof EdDSAPrivateKey) && (k2 instanceof EdDSAPrivateKey)) {
-            if (Objects.equals(k1, k2)) {
+            if (k1.equals(k2)) {
                 return true;
-            } else if (k1 == null || k2 == null) {
-                return false; // both null is covered by Objects#equals
             }
 
             EdDSAPrivateKey ed1 = (EdDSAPrivateKey) k1;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/SignatureEd25519.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/SignatureEd25519.java
index f5dcba522..bba78751d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/SignatureEd25519.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/SignatureEd25519.java
@@ -38,7 +38,7 @@ public class SignatureEd25519 extends AbstractSignature {
     public boolean verify(SessionContext session, byte[] sig) throws Exception {
         byte[] data = sig;
         Map.Entry<String, byte[]> encoding
-                = extractEncodedSignature(data, k -> KeyPairProvider.SSH_ED25519.equalsIgnoreCase(k));
+                = extractEncodedSignature(data, KeyPairProvider.SSH_ED25519::equalsIgnoreCase);
         if (encoding != null) {
             String keyType = encoding.getKey();
             ValidateUtils.checkTrue(
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
index b93e81ed5..9f2b3be73 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
@@ -241,7 +241,7 @@ public final class ThreadUtils {
                         Thread thread = Thread.currentThread();
                         return thread.getContextClassLoader();
                     },
-                    () -> effectiveAnchor.getClassLoader(),
+                    effectiveAnchor::getClassLoader,
                     ClassLoader::getSystemClassLoader
             };
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProvider.java b/sshd-common/src/main/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProvider.java
index 67a2565a9..f8cb53334 100644
--- a/sshd-common/src/main/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProvider.java
@@ -123,7 +123,7 @@ public abstract class AbstractGeneratorHostKeyProvider
             ids = keyPairHolder.getAndSet(null);
         }
 
-        if ((ids != null) & log.isDebugEnabled()) {
+        if ((ids != null) && log.isDebugEnabled()) {
             log.debug("clearLoadedKeys({}) removed keys", getPath());
         }
     }
@@ -287,7 +287,7 @@ public abstract class AbstractGeneratorHostKeyProvider
         KeyPairGenerator generator = SecurityUtils.getKeyPairGenerator(algorithm);
         if (keySpec != null) {
             generator.initialize(keySpec);
-            log.info("generateKeyPair(" + algorithm + ") generating host key - spec=" + keySpec.getClass().getSimpleName());
+            log.info("generateKeyPair({}) generating host key - spec={}", algorithm, keySpec.getClass().getSimpleName());
         } else if (KeyUtils.EC_ALGORITHM.equals(algorithm)) {
             ECCurves curve;
             // If left to our own devices choose the biggest key size possible
@@ -301,10 +301,10 @@ public abstract class AbstractGeneratorHostKeyProvider
                 }
             }
             generator.initialize(curve.getParameters());
-            log.info("generateKeyPair(" + algorithm + ") generating host key=" + curve);
+            log.info("generateKeyPair({}) generating host key={}", algorithm, curve);
         } else if (keySize != 0) {
             generator.initialize(keySize);
-            log.info("generateKeyPair(" + algorithm + ") generating host key - size=" + keySize);
+            log.info("generateKeyPair({}) generating host key - size={}", algorithm, keySize);
         }
 
         return generator.generateKeyPair();
diff --git a/sshd-common/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java b/sshd-common/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
index ec8d53dce..2a3944c0a 100644
--- a/sshd-common/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
+++ b/sshd-common/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
@@ -153,7 +153,7 @@ public class BuiltinClientIdentitiesWatcherTest extends JUnitTestSupport {
     }
 
     private static void testMultipleFilesWatch(
-            String phase, KeyIdentityProvider watcher, Collection<? extends KeyPair> expected)
+            String phase, KeyIdentityProvider watcher, Collection<KeyPair> expected)
             throws IOException, GeneralSecurityException {
         Iterable<KeyPair> keys = watcher.loadKeys(null);
         Collection<KeyPair> actual = new ArrayList<>();
diff --git a/sshd-common/src/test/java/org/apache/sshd/common/config/keys/writer/openssh/OpenSSHKeyPairResourceWriterTest.java b/sshd-common/src/test/java/org/apache/sshd/common/config/keys/writer/openssh/OpenSSHKeyPairResourceWriterTest.java
index f042f8d23..e25567d1a 100644
--- a/sshd-common/src/test/java/org/apache/sshd/common/config/keys/writer/openssh/OpenSSHKeyPairResourceWriterTest.java
+++ b/sshd-common/src/test/java/org/apache/sshd/common/config/keys/writer/openssh/OpenSSHKeyPairResourceWriterTest.java
@@ -53,10 +53,8 @@ import org.apache.sshd.util.test.JUnitTestSupport;
 import org.apache.sshd.util.test.NoIoTestCase;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
 import org.junit.runners.MethodSorters;
 import org.junit.runners.Parameterized;
@@ -68,8 +66,6 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory;
 @UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
 @Category({ NoIoTestCase.class })
 public class OpenSSHKeyPairResourceWriterTest extends JUnitTestSupport {
-    @Rule
-    public TemporaryFolder folder = new TemporaryFolder();
 
     private final TestData data;
     private KeyPair testKey;
diff --git a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
index 6d4758c4a..829f25bcd 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
@@ -462,7 +462,7 @@ public final class CommonTestSupportUtils {
 
     public static KeyPair getFirstKeyPair(KeyIdentityProvider provider) {
         Objects.requireNonNull(provider, "No key pair provider");
-        Iterable<? extends KeyPair> pairs;
+        Iterable<KeyPair> pairs;
         try {
             pairs = Objects.requireNonNull(provider.loadKeys(null), "No loaded keys");
         } catch (IOException | GeneralSecurityException e) {
@@ -471,7 +471,7 @@ public final class CommonTestSupportUtils {
                     e);
         }
 
-        Iterator<? extends KeyPair> iter = Objects.requireNonNull(pairs.iterator(), "No keys iterator");
+        Iterator<KeyPair> iter = Objects.requireNonNull(pairs.iterator(), "No keys iterator");
         ValidateUtils.checkTrue(iter.hasNext(), "Empty loaded kyes iterator");
         return Objects.requireNonNull(iter.next(), "No key pair in iterator");
     }
diff --git a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/channel/throttle/ThrottlingChannelStreamWriter.java b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/channel/throttle/ThrottlingChannelStreamWriter.java
index addf08860..bf8a654dc 100644
--- a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/channel/throttle/ThrottlingChannelStreamWriter.java
+++ b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/channel/throttle/ThrottlingChannelStreamWriter.java
@@ -197,7 +197,7 @@ public class ThrottlingChannelStreamWriter extends AbstractLoggingBean
     public void close() throws IOException {
         if (open.getAndSet(false)) {
             if (log.isDebugEnabled()) {
-                log.debug("close({}) closing");
+                log.debug("close({}) closing", this);
             }
         }
 
diff --git a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
index 63afc604d..8bb963ecb 100644
--- a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
+++ b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
@@ -244,7 +244,7 @@ public class LegacyDSASigner extends java.security.Signature {
             }
 
             BigInteger q = params.getQ();
-            if ((r.compareTo(q) != -1) || (s.compareTo(q) != -1)) {
+            if ((r.compareTo(q) >= 0) || (s.compareTo(q) >= 0)) {
                 throw new IndexOutOfBoundsException("Out of range values in signature");
             }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java
index a0fa391a9..8548cb69a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java
@@ -242,7 +242,7 @@ public abstract class AbstractAgentProxy extends AbstractLoggingBean implements
         if ((service != null) && (!service.isShutdown())) {
             Collection<?> runners = service.shutdownNow();
             if (log.isDebugEnabled()) {
-                log.debug("close() - shutdown runners count=" + GenericUtils.size(runners));
+                log.debug("close() - shutdown runners count={}", GenericUtils.size(runners));
             }
         }
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java
index 66cff0fa8..7cd0b53f0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java
@@ -54,9 +54,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer
             return channel.getAgent();
         } catch (Throwable t) {
             if (log.isDebugEnabled()) {
-                log.warn("createClient(" + service.getSession() + ")[" + getId() + ")"
-                         + " failed (" + t.getClass().getSimpleName() + ")"
-                         + " to create client: " + t.getMessage());
+                log.warn("createClient({})[{}] failed to create client: {}", service.getSession(), getId(), t.toString());
             }
 
             if (t instanceof IOException) {
@@ -81,7 +79,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer
     public void close() throws IOException {
         if (open.getAndSet(false)) {
             if (log.isDebugEnabled()) {
-                log.debug("closed(" + service.getSession() + ")[" + getId() + "]");
+                log.debug("closed({})[{}]", service.getSession(), getId());
             }
         }
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java
index 59f47ede3..9dac098a6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java
@@ -125,7 +125,7 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu
         if ((executor != null) && (!executor.isShutdown())) {
             Collection<?> runners = executor.shutdownNow();
             if (log.isDebugEnabled()) {
-                log.debug("Shut down runners count=" + GenericUtils.size(runners));
+                log.debug("Shut down runners count={}", GenericUtils.size(runners));
             }
         }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java
index d88532937..cb49b5d8a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java
@@ -179,7 +179,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer
         if ((executor != null) && (!executor.isShutdown())) {
             Collection<?> runners = executor.shutdownNow();
             if (debugEnabled) {
-                log.debug("Shut down runners count=" + GenericUtils.size(runners));
+                log.debug("Shut down runners count={}", GenericUtils.size(runners));
             }
         }
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java
index 43921f4db..505b99298 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java
@@ -56,12 +56,10 @@ public final class AprLibrary {
     private AprLibrary() {
         try {
             Library.initialize(null);
+        } catch (RuntimeException e) {
+            throw e;
         } catch (Throwable e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            } else {
-                throw new RuntimeException("Error loading Apache Portable Runtime (APR).", e);
-            }
+            throw new RuntimeException("Error loading Apache Portable Runtime (APR).", e);
         }
         pool = Pool.create(0);
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index 11091d979..e24274b68 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -132,7 +132,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
             if (forwardService != null) {
                 Collection<?> runners = forwardService.shutdownNow();
                 if (log.isDebugEnabled()) {
-                    log.debug("Shut down runners count=" + GenericUtils.size(runners));
+                    log.debug("Shut down runners count={}", GenericUtils.size(runners));
                 }
             }
         } finally {
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
index e74695415..2df1f8619 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
@@ -43,7 +43,7 @@ public class DefaultConnectFuture extends DefaultVerifiableSshFuture<ConnectFutu
         long endTime = System.nanoTime();
         if (log.isDebugEnabled()) {
             IoSession ioSession = session.getIoSession();
-            log.debug("Connected to " + ioSession.getRemoteAddress() + " after " + (endTime - startTime) + " nanos");
+            log.debug("Connected to {} after {} nanos", ioSession.getRemoteAddress(), endTime - startTime);
         }
         return this;
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 014cc46c0..202ef8fd2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -346,11 +346,7 @@ public abstract class AbstractChannel extends AbstractInnerCloseable implements
         }
 
         if (RequestHandler.Result.Replied.equals(result) || (!wantReply)) {
-            return new AbstractIoWriteFuture(req, null) {
-                {
-                    setValue(Boolean.TRUE);
-                }
-            };
+            return AbstractIoWriteFuture.fulfilled(req, Boolean.TRUE);
         }
 
         byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
@@ -412,14 +408,10 @@ public abstract class AbstractChannel extends AbstractInnerCloseable implements
                 signalChannelOpenSuccess(l);
                 return null;
             });
+        } catch (Error | RuntimeException err) {
+            throw err;
         } catch (Throwable err) {
-            if (err instanceof RuntimeException) {
-                throw (RuntimeException) err;
-            } else if (err instanceof Error) {
-                throw (Error) err;
-            } else {
-                throw new RuntimeException(err);
-            }
+            throw new RuntimeException(err);
         }
     }
 
@@ -782,11 +774,7 @@ public abstract class AbstractChannel extends AbstractInnerCloseable implements
         if (log.isDebugEnabled()) {
             log.debug("writePacket({}) Discarding output packet because channel state={}", this, state);
         }
-        return new AbstractIoWriteFuture(toString(), null) {
-            {
-                setValue(new EOFException("Channel is being closed"));
-            }
-        };
+        return AbstractIoWriteFuture.fulfilled(toString(), new EOFException("Channel is being closed"));
     }
 
     protected boolean mayWrite() {
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
index f50f03019..1e3a23c35 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
@@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.sshd.common.Closeable;
 import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.channel.exception.SshChannelBufferedOutputException;
-import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.util.ValidateUtils;
@@ -187,16 +186,13 @@ public class BufferedIoOutputStream extends AbstractInnerCloseable implements Io
 
         Buffer buffer = future.getBuffer();
         int bufferSize = buffer.available();
-        out.writeBuffer(buffer).addListener(new SshFutureListener<IoWriteFuture>() {
-            @Override
-            public void operationComplete(IoWriteFuture f) {
-                if (f.isWritten()) {
-                    future.setValue(Boolean.TRUE);
-                } else {
-                    future.setValue(f.getException());
-                }
-                finishWrite(future, bufferSize);
+        out.writeBuffer(buffer).addListener(f -> {
+            if (f.isWritten()) {
+                future.setValue(Boolean.TRUE);
+            } else {
+                future.setValue(f.getException());
             }
+            finishWrite(future, bufferSize);
         });
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
index 7d8c66bb8..54617109c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
@@ -172,7 +172,7 @@ public class ChannelAsyncInputStream extends AbstractCloseable implements IoInpu
             Number result = verifyResult(Number.class, timeoutMillis);
             long endTime = System.nanoTime();
             if (log.isDebugEnabled()) {
-                log.debug("Read " + result + " bytes after " + (endTime - startTime) + " nanos");
+                log.debug("Read {} bytes after {} nanos", result, endTime - startTime);
             }
 
             return this;
@@ -197,7 +197,7 @@ public class ChannelAsyncInputStream extends AbstractCloseable implements IoInpu
                 throw formatExceptionMessage(
                         IllegalStateException::new,
                         "Unknown read value type: %s",
-                        (v == null) ? "null" : v.getClass().getName());
+                        v.getClass().getName());
             }
         }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
index 2b7176538..eb4aa3875 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
@@ -223,7 +223,7 @@ public class DefaultForwarder
 
         try {
             if (log.isDebugEnabled()) {
-                log.debug("startLocalPortForwarding(" + local + " -> " + remote + "): " + result);
+                log.debug("startLocalPortForwarding({} -> {}): {}", local, remote, result);
             }
             signalEstablishedExplicitTunnel(local, remote, true, result, null);
             return result;
@@ -325,7 +325,7 @@ public class DefaultForwarder
         try {
             SshdSocketAddress bound = new SshdSocketAddress(remoteHost, port);
             if (log.isDebugEnabled()) {
-                log.debug("startRemotePortForwarding(" + remote + " -> " + local + "): " + bound);
+                log.debug("startRemotePortForwarding({} -> {}): {}", remote, local, bound);
             }
 
             signalEstablishedExplicitTunnel(local, remote, false, bound, null);
@@ -346,7 +346,7 @@ public class DefaultForwarder
 
         if (bound != null) {
             if (log.isDebugEnabled()) {
-                log.debug("stopRemotePortForwarding(" + remote + ") cancel forwarding to " + bound);
+                log.debug("stopRemotePortForwarding({}) cancel forwarding to {}", remote, bound);
             }
 
             String remoteHost = remote.getHostName();
@@ -368,7 +368,7 @@ public class DefaultForwarder
             signalTornDownExplicitTunnel(bound, false, remote, null);
         } else {
             if (log.isDebugEnabled()) {
-                log.debug("stopRemotePortForwarding(" + remote + ") no binding found");
+                log.debug("stopRemotePortForwarding({}) no binding found", remote);
             }
         }
     }
@@ -381,19 +381,13 @@ public class DefaultForwarder
                 signalTearingDownExplicitTunnel(l, boundAddress, localForwarding, remote);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal tearing down explicit tunnel for local=" + localForwarding
-                                      + " on bound=" + boundAddress,
-                        t);
-            }
+            throw new IOException(
+                    "Failed (" + t.getClass().getSimpleName() + ")" + " to signal tearing down explicit tunnel for local="
+                                  + localForwarding + " on bound=" + boundAddress,
+                    t);
         }
     }
 
@@ -416,19 +410,13 @@ public class DefaultForwarder
                 signalTornDownExplicitTunnel(l, boundAddress, localForwarding, remoteAddress, reason);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal torn down explicit tunnel local=" + localForwarding
-                                      + " on bound=" + boundAddress,
-                        t);
-            }
+            throw new IOException(
+                    "Failed (" + t.getClass().getSimpleName() + ")" + " to signal torn down explicit tunnel local="
+                                  + localForwarding + " on bound=" + boundAddress,
+                    t);
         }
     }
 
@@ -489,7 +477,7 @@ public class DefaultForwarder
         try {
             SshdSocketAddress result = new SshdSocketAddress(bound.getHostString(), port);
             if (log.isDebugEnabled()) {
-                log.debug("startDynamicPortForwarding(" + local + "): " + result);
+                log.debug("startDynamicPortForwarding({}): {}", local, result);
             }
 
             signalEstablishedDynamicTunnel(local, result, null);
@@ -508,19 +496,12 @@ public class DefaultForwarder
                 signalEstablishedDynamicTunnel(l, local, boundAddress, reason);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal establishing dynamic tunnel for local=" + local
-                                      + " on bound=" + boundAddress,
-                        t);
-            }
+            throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+                                  + " to signal establishing dynamic tunnel for local=" + local + " on bound=" + boundAddress,
+                    t);
         }
     }
 
@@ -541,18 +522,12 @@ public class DefaultForwarder
                 signalEstablishingDynamicTunnel(l, local);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal establishing dynamic tunnel for local=" + local,
-                        t);
-            }
+            throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+                                  + " to signal establishing dynamic tunnel for local=" + local,
+                    t);
         }
     }
 
@@ -629,18 +604,12 @@ public class DefaultForwarder
                 signalTearingDownDynamicTunnel(l, address);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal tearing down dynamic tunnel for address=" + address,
-                        t);
-            }
+            throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+                                  + " to signal tearing down dynamic tunnel for address=" + address,
+                    t);
         }
     }
 
@@ -659,18 +628,12 @@ public class DefaultForwarder
                 signalTornDownDynamicTunnel(l, address, reason);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal torn down dynamic tunnel for address=" + address,
-                        t);
-            }
+            throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+                                  + " to signal torn down dynamic tunnel for address=" + address,
+                    t);
         }
     }
 
@@ -702,8 +665,7 @@ public class DefaultForwarder
         try {
             if ((filter == null) || (!filter.canListen(local, session))) {
                 if (log.isDebugEnabled()) {
-                    log.debug("localPortForwardingRequested(" + session + ")[" + local + "][haveFilter=" + (filter != null)
-                              + "] rejected");
+                    log.debug("localPortForwardingRequested({})[{}][haveFilter={}] rejected", session, local, filter != null);
                 }
                 return null;
             }
@@ -720,7 +682,7 @@ public class DefaultForwarder
             InetSocketAddress bound = doBind(local, getLocalIoAcceptor());
             result = new SshdSocketAddress(bound);
             if (log.isDebugEnabled()) {
-                log.debug("localPortForwardingRequested(" + local + "): " + result);
+                log.debug("localPortForwardingRequested({}): {}", local, result);
             }
 
             boolean added;
@@ -742,12 +704,8 @@ public class DefaultForwarder
             throw e;
         }
 
-        try {
-            signalEstablishedExplicitTunnel(local, null, true, result, null);
-            return result;
-        } catch (IOException | RuntimeException e) {
-            throw e;
-        }
+        signalEstablishedExplicitTunnel(local, null, true, result, null);
+        return result;
     }
 
     @Override
@@ -763,7 +721,7 @@ public class DefaultForwarder
 
         if ((entry != null) && (localAcceptor != null)) {
             if (log.isDebugEnabled()) {
-                log.debug("localPortForwardingCancelled(" + local + ") unbind " + entry);
+                log.debug("localPortForwardingCancelled({}) unbind {}", local, entry);
             }
 
             SshdSocketAddress reportedBoundAddress = entry.getCombinedBoundAddress();
@@ -780,7 +738,7 @@ public class DefaultForwarder
             signalTornDownExplicitTunnel(reportedBoundAddress, true, null, null);
         } else {
             if (log.isDebugEnabled()) {
-                log.debug("localPortForwardingCancelled(" + local + ") no match/acceptor: " + entry);
+                log.debug("localPortForwardingCancelled({}) no match/acceptor: {}", local, entry);
             }
         }
     }
@@ -793,19 +751,13 @@ public class DefaultForwarder
                 signalEstablishingExplicitTunnel(l, local, remote, localForwarding);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal establishing explicit tunnel for local=" + local
-                                      + ", remote=" + remote + ", localForwarding=" + localForwarding,
-                        t);
-            }
+            throw new IOException(
+                    "Failed (" + t.getClass().getSimpleName() + ")" + " to signal establishing explicit tunnel for local="
+                                  + local + ", remote=" + remote + ", localForwarding=" + localForwarding,
+                    t);
         }
     }
 
@@ -828,20 +780,13 @@ public class DefaultForwarder
                 signalEstablishedExplicitTunnel(l, local, remote, localForwarding, boundAddress, reason);
                 return null;
             });
+        } catch (Error | RuntimeException | IOException e) {
+            throw e;
         } catch (Throwable t) {
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else if (t instanceof Error) {
-                throw (Error) t;
-            } else if (t instanceof IOException) {
-                throw (IOException) t;
-            } else {
-                throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
-                                      + " to signal established explicit tunnel for local=" + local
-                                      + ", remote=" + remote + ", localForwarding=" + localForwarding
-                                      + ", bound=" + boundAddress,
-                        t);
-            }
+            throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+                                  + " to signal established explicit tunnel for local=" + local + ", remote=" + remote
+                                  + ", localForwarding=" + localForwarding + ", bound=" + boundAddress,
+                    t);
         }
     }
 
@@ -1155,13 +1100,7 @@ public class DefaultForwarder
     @Override
     public boolean isLocalPortForwardingStartedForPort(int port) {
         synchronized (localLock) {
-            return localToRemote.isEmpty()
-                    ? false
-                    : localToRemote.keySet()
-                            .stream()
-                            .filter(e -> e.getPort() == port)
-                            .findAny()
-                            .isPresent();
+            return localToRemote.keySet().stream().anyMatch(e -> e.getPort() == port);
         }
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
index e64baf2c9..58abd27c5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
@@ -88,12 +88,10 @@ public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFa
         Class<? extends IoServiceFactoryFactory> clazz = getFactoryClass();
         try {
             return ReflectionUtils.newInstance(clazz, IoServiceFactoryFactory.class);
+        } catch (RuntimeException | Error e) {
+            throw e;
         } catch (Throwable e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            } else {
-                throw new RuntimeException(e);
-            }
+            throw new RuntimeException(e);
         }
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
index 4b29d4255..e84b24d6c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
@@ -65,8 +65,7 @@ public class DefaultIoServiceFactoryFactory extends AbstractIoServiceFactoryFact
             factory = newInstance(IoServiceFactoryFactory.class);
             if (factory == null) {
                 factory = BuiltinIoServiceFactoryFactories.NIO2.create();
-                log.info("No detected/configured " + IoServiceFactoryFactory.class.getSimpleName()
-                         + " using " + factory.getClass().getSimpleName());
+                log.info("No detected/configured IoServiceFactoryFactory; using {}", factory.getClass().getSimpleName());
             } else {
                 log.info("Using {}", factory.getClass().getSimpleName());
             }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
index d64dc1e94..82f869fe3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
@@ -202,10 +202,8 @@ public abstract class Nio2Service extends AbstractInnerCloseable implements IoSe
             }
             return true;
         } catch (IOException | RuntimeException e) {
-            log.warn("Unable (" + e.getClass().getSimpleName() + ")"
-                     + " to set socket option " + option
-                     + " using property " + property + "=" + val
-                     + ": " + e.getMessage());
+            log.warn("setOption({}): unable to set socket option {} via {}={}: {}", socket, option, property, val,
+                    e.toString());
             return false;
         }
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
index 3843dc974..746484b67 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
@@ -112,7 +112,7 @@ public abstract class AbstractDHKeyExchange extends AbstractLoggingBean implemen
         }
     }
 
-    protected void validateEValue(BigInteger pValue) throws Exception {
+    protected void validateEValue(BigInteger pValue) throws SshException {
         BigInteger value = Objects.requireNonNull(getEValue(), "No DH 'e' value set");
         if (!KeyExchange.isValidDHValue(value, pValue)) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
@@ -149,7 +149,7 @@ public abstract class AbstractDHKeyExchange extends AbstractLoggingBean implemen
         }
     }
 
-    protected void validateFValue(BigInteger pValue) throws Exception {
+    protected void validateFValue(BigInteger pValue) throws SshException {
         BigInteger value = Objects.requireNonNull(getFValue(), "No DH 'f' value set");
         if (!KeyExchange.isValidDHValue(value, pValue)) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index d585a6ced..70e9f1279 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -900,11 +900,7 @@ public abstract class AbstractConnectionService
         }
 
         if (RequestHandler.Result.Replied.equals(result) || (!wantReply)) {
-            return new AbstractIoWriteFuture(req, null) {
-                {
-                    setValue(Boolean.TRUE);
-                }
-            };
+            return AbstractIoWriteFuture.fulfilled(req, Boolean.TRUE);
         }
 
         byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 22e68c656..8b51d8eba 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -273,7 +273,7 @@ public abstract class AbstractSession extends SessionHelper {
      * @see {@link #doInvokeUnimplementedMessageHandler(int, Buffer)}
      * @see {@link #preClose()}
      */
-    private final Deque<GlobalRequestFuture> pendingGlobalRequests = new ConcurrentLinkedDeque<GlobalRequestFuture>();
+    private final Deque<GlobalRequestFuture> pendingGlobalRequests = new ConcurrentLinkedDeque<>();
 
     private final Map<Buffer, LongConsumer> globalSequenceNumbers = new ConcurrentHashMap<>();
 
@@ -314,12 +314,10 @@ public abstract class AbstractSession extends SessionHelper {
 
         try {
             signalSessionEstablished(ioSession);
+        } catch (RuntimeException e) {
+            throw e;
         } catch (Exception e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            } else {
-                throw new RuntimeSshException(e);
-            }
+            throw new RuntimeSshException(e);
         }
     }
 
@@ -1723,7 +1721,7 @@ public abstract class AbstractSession extends SessionHelper {
         IoWriteFuture future = (handler == null) ? null : handler.sendKexInitRequest(this, proposal, buffer);
         byte[] data = buffer.getCompactData();
         if (future == null) {
-            future = writePacket(buffer);
+            writePacket(buffer);
         } else {
             if (debugEnabled) {
                 log.debug("sendKexInit({}) KEX handled by reserved messages handler", this);
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSessionIoHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSessionIoHandler.java
index d176a258b..136eb2cf5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSessionIoHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSessionIoHandler.java
@@ -63,8 +63,10 @@ public abstract class AbstractSessionIoHandler extends AbstractLoggingBean imple
         try {
             session.messageReceived(message);
         } catch (Error e) {
-            log.debug("messageReceived({}) failed {} to handle message: {}",
-                    ioSession, e.getClass().getSimpleName(), e.getMessage(), e);
+            if (log.isDebugEnabled()) {
+                log.debug("messageReceived({}) failed {} to handle message: {}", ioSession, e.getClass().getSimpleName(),
+                        e.getMessage(), e);
+            }
             throw new RuntimeSshException(e);
         }
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
index 59018d6b8..294935a0a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
@@ -184,7 +184,7 @@ public class KeyExchangeMessageHandler {
             if (numPending == 0) {
                 kexFlushed = true;
             }
-            return new SimpleImmutableEntry<Integer, DefaultKeyExchangeFuture>(Integer.valueOf(numPending), kexFlushedFuture);
+            return new SimpleImmutableEntry<>(Integer.valueOf(numPending), kexFlushedFuture);
         });
     }
 
@@ -518,9 +518,7 @@ public class KeyExchangeMessageHandler {
                 }
                 // Connect all futures of packets that we wrote. We do this at the end instead of one-by-one inside the
                 // loop to minimize the risk that woken up threads waiting on these futures queue up additional packets.
-                pendingFutures.forEach(e -> {
-                    e.getValue().addListener(e.getKey());
-                });
+                pendingFutures.forEach(e -> e.getValue().addListener(e.getKey()));
             }
         });
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index 1bb2ffa86..8900d2dd0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -332,7 +332,7 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa
                     if (port == 0) {
                         SocketAddress selectedAddress = GenericUtils.head(acceptor.getBoundAddresses());
                         port = ((InetSocketAddress) selectedAddress).getPort();
-                        log.info("start() listen on auto-allocated port=" + port);
+                        log.info("start() listen on auto-allocated port={}", port);
                     }
                 }
             }
@@ -341,7 +341,7 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa
             if (port == 0) {
                 SocketAddress selectedAddress = GenericUtils.head(acceptor.getBoundAddresses());
                 port = ((InetSocketAddress) selectedAddress).getPort();
-                log.info("start() listen on auto-allocated port=" + port);
+                log.info("start() listen on auto-allocated port={}", port);
             }
         }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/AsyncAuthException.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/AsyncAuthException.java
index ade64d8af..105463bb1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/AsyncAuthException.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/AsyncAuthException.java
@@ -31,7 +31,7 @@ public class AsyncAuthException extends RuntimeSshException {
 
     private static final long serialVersionUID = 6741236101797649869L;
 
-    protected Object listener;
+    protected transient Object listener;
     protected Boolean authed;
 
     public AsyncAuthException() {
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
index 72fa92cc1..0c8db6863 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
@@ -120,7 +120,7 @@ public class UserAuthGSS extends AbstractUserAuth {
         } else {
             int msg = buffer.getUByte();
             if (!((msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE)
-                    || ((msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC)) && context.isEstablished())) {
+                    || ((msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC) && context.isEstablished()))) {
                 throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
                         "Packet not supported by user authentication method: " + SshConstants.getCommandMessageName(msg));
             }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
index cb8dc478a..8650aa8f9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
@@ -79,7 +79,7 @@ public class AuthorizedKeyEntriesPublickeyAuthenticator extends AbstractLoggingB
     public boolean authenticate(String username, PublicKey key, ServerSession session) {
         if (MapEntryUtils.isEmpty(resolvedKeys)) {
             if (log.isDebugEnabled()) {
-                log.debug("authenticate(" + username + ")[" + session + "] no entries");
+                log.debug("authenticate({})[{}] no entries", username, session);
             }
 
             return false;
@@ -88,7 +88,7 @@ public class AuthorizedKeyEntriesPublickeyAuthenticator extends AbstractLoggingB
         for (Map.Entry<AuthorizedKeyEntry, PublicKey> e : resolvedKeys.entrySet()) {
             if (KeyUtils.compareKeys(key, e.getValue())) {
                 if (log.isDebugEnabled()) {
-                    log.debug("authenticate(" + username + ")[" + session + "] match found");
+                    log.debug("authenticate({})[{}] match found", username, session);
                 }
                 if (session != null) {
                     session.setAttribute(AUTHORIZED_KEY, e.getKey());
@@ -98,7 +98,7 @@ public class AuthorizedKeyEntriesPublickeyAuthenticator extends AbstractLoggingB
         }
 
         if (log.isDebugEnabled()) {
-            log.debug("authenticate(" + username + ")[" + session + "] match not found");
+            log.debug("authenticate({})[{}] match not found", username, session);
         }
         return false;
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
index a48f5a3bf..3eb87d50c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
@@ -59,7 +59,7 @@ public class KeySetPublickeyAuthenticator extends AbstractLoggingBean implements
     public boolean authenticate(String username, PublicKey key, ServerSession session, Collection<? extends PublicKey> keys) {
         if (GenericUtils.isEmpty(keys)) {
             if (log.isDebugEnabled()) {
-                log.debug("authenticate(" + username + ")[" + session + "] no keys");
+                log.debug("authenticate({})[{}] no keys", username, session);
             }
 
             return false;
@@ -68,7 +68,7 @@ public class KeySetPublickeyAuthenticator extends AbstractLoggingBean implements
         PublicKey matchKey = KeyUtils.findMatchingKey(key, keys);
         boolean matchFound = matchKey != null;
         if (log.isDebugEnabled()) {
-            log.debug("authenticate(" + username + ")[" + session + "] match found=" + matchFound);
+            log.debug("authenticate({})[{}] match found={}", username, session, matchFound);
         }
         return matchFound;
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
index 310a8e47c..ff04db301 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
@@ -73,10 +73,8 @@ public class PuttyRequestHandler extends AbstractChannelRequestHandler {
         }
 
         if (log.isDebugEnabled()) {
-            log.debug("processPuttyOpcode(" + opcode + ")"
-                      + "[buffer size=" + buffer.available() + "]"
-                      + "[reply=" + wantReply + "]"
-                      + " Unknown request: " + request);
+            log.debug("processPuttyOpcode({})[buffer size={}] [reply={}] Unknown request: {}", opcode, buffer.available(),
+                    wantReply, request);
         }
 
         return Result.ReplyFailure;
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractCommandSupport.java b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractCommandSupport.java
index 55dc4a7f3..9618d7352 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractCommandSupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractCommandSupport.java
@@ -159,11 +159,7 @@ public abstract class AbstractCommandSupport
                 this.run();
             });
         } catch (RuntimeException e) { // e.g., RejectedExecutionException
-            log.error("start(" + channel + ")"
-                      + " Failed (" + e.getClass().getSimpleName() + ")"
-                      + " to start command=" + cmd + ": " + e.getMessage(),
-                    e);
-            throw new IOException(e);
+            throw new IOException("start(" + channel + ") failed to start command " + cmd, e);
         }
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
index 970e39d3c..8be966b4e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
@@ -35,7 +35,7 @@ public abstract class AbstractFileSystemCommand extends AbstractCommandSupport i
 
     protected FileSystem fileSystem;
 
-    public AbstractFileSystemCommand(String command, CloseableExecutorService executorService) {
+    protected AbstractFileSystemCommand(String command, CloseableExecutorService executorService) {
         super(command, executorService);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
index 4bcd713d2..c66978d2c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
@@ -28,6 +28,6 @@ public class DirectTcpipFactory extends TcpipFactory {
     public static final DirectTcpipFactory INSTANCE = new DirectTcpipFactory();
 
     public DirectTcpipFactory() {
-        super(ForwardingFilter.Type.Direct);
+        super(TcpForwardingFilter.Type.Direct);
     }
 }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
index 15ef75b49..4975e16dd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
@@ -28,6 +28,6 @@ public class ForwardedTcpipFactory extends TcpipFactory {
     public static final ForwardedTcpipFactory INSTANCE = new ForwardedTcpipFactory();
 
     public ForwardedTcpipFactory() {
-        super(ForwardingFilter.Type.Forwarded);
+        super(TcpForwardingFilter.Type.Forwarded);
     }
 }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
index fb8a1cef8..29e7d6542 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
@@ -68,7 +68,7 @@ public class StaticDecisionForwardingFilter extends AbstractLoggingBean implemen
     protected boolean checkAcceptance(String request, Session session, SshdSocketAddress target) {
         boolean accepted = isAccepted();
         if (log.isDebugEnabled()) {
-            log.debug("checkAcceptance(" + request + ")[" + session + "] acceptance for target=" + target + " is " + accepted);
+            log.debug("checkAcceptance({})[{}] acceptance for target={} is {}", request, session, target, accepted);
         }
         return accepted;
     }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index f4faf24a0..f71dba90e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -65,13 +65,13 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
 
     public abstract static class TcpipFactory implements ChannelFactory, ExecutorServiceCarrier {
 
-        private final ForwardingFilter.Type type;
+        private final TcpForwardingFilter.Type type;
 
-        protected TcpipFactory(ForwardingFilter.Type type) {
+        protected TcpipFactory(TcpForwardingFilter.Type type) {
             this.type = type;
         }
 
-        public final ForwardingFilter.Type getType() {
+        public final TcpForwardingFilter.Type getType() {
             return type;
         }
 
@@ -91,7 +91,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
         }
     }
 
-    private final ForwardingFilter.Type type;
+    private final TcpForwardingFilter.Type type;
     private IoConnector connector;
     private ChannelToPortHandler port;
     private ChannelAsyncOutputStream out;
@@ -100,12 +100,12 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
     private SshdSocketAddress originatorAddress;
     private SocketAddress localAddress;
 
-    public TcpipServerChannel(ForwardingFilter.Type type, CloseableExecutorService executor) {
+    public TcpipServerChannel(TcpForwardingFilter.Type type, CloseableExecutorService executor) {
         super("", Collections.emptyList(), executor);
         this.type = Objects.requireNonNull(type, "No channel type specified");
     }
 
-    public ForwardingFilter.Type getTcpipChannelType() {
+    public TcpForwardingFilter.Type getTcpipChannelType() {
         return type;
     }
 
@@ -178,8 +178,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
         try {
             if ((address == null) || (filter == null) || (!filter.canConnect(channelType, address, session))) {
                 if (debugEnabled) {
-                    log.debug(
-                            "doInit(" + this + ")[" + type + "][haveFilter=" + (filter != null) + "] filtered out " + address);
+                    log.debug("doInit({})[{}][haveFilter={}] filtered out {}", this, type, filter != null, address);
                 }
                 try {
                     f.setException(new SshChannelOpenException(getChannelId(),
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index d56e231e9..06b44d593 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -533,11 +533,9 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
             if (CoreModuleProperties.AUTO_WELCOME_BANNER_VALUE.equalsIgnoreCase(message)) {
                 try {
                     return KeyRandomArt.combine(session, ' ', session.getKeyPairProvider());
+                } catch (IOException e) {
+                    throw e;
                 } catch (Exception e) {
-                    if (e instanceof IOException) {
-                        throw (IOException) e;
-                    }
-
                     throw new IOException(e);
                 }
             }
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
index 59abec810..1fdd47092 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
@@ -83,7 +83,7 @@ public class ChannelPipedInputStreamTest extends BaseTestSupport {
         } else {
             assertArrayEquals("Mismatched stream content", expected, Arrays.copyOf(read, expected.length));
             for (int i = expected.length; i < read.length; i++) {
-                assertTrue("Non-zero value at position " + i, read[i] == 0);
+                assertEquals("Non-zero value at position " + i, 0, read[i]);
             }
         }
     }
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/AbstractGitCommand.java b/sshd-git/src/main/java/org/apache/sshd/git/AbstractGitCommand.java
index 3e96e3f9e..7aa60b43f 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/AbstractGitCommand.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/AbstractGitCommand.java
@@ -20,7 +20,6 @@
 package org.apache.sshd.git;
 
 import java.io.OutputStream;
-import java.nio.file.FileSystem;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -43,7 +42,6 @@ public abstract class AbstractGitCommand
     public static final int ENDQUOTE = 0x008;
 
     protected final GitLocationResolver rootDirResolver;
-    protected FileSystem fileSystem;
 
     protected AbstractGitCommand(GitLocationResolver rootDirResolver, String command,
                                  CloseableExecutorService executorService) {
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java b/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
index e9f2de8eb..bd102014b 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
@@ -65,7 +65,6 @@ public class GitPackCommand extends AbstractGitCommand {
                 }
                 if (argVal.startsWith("\"") && argVal.endsWith("\"")) {
                     args[i] = argVal.substring(1, argVal.length() - 1);
-                    argVal = args[i];
                 }
             }
 
@@ -100,8 +99,7 @@ public class GitPackCommand extends AbstractGitCommand {
         int len = GenericUtils.length(pathArg);
         // Strip any leading path separator since we use relative to root
         if ((len > 0) && (pathArg.charAt(0) == '/')) {
-            pathArg = (len > 1) ? pathArg.substring(1) : "";
-            len--;
+            pathArg = pathArg.substring(1);
         }
 
         ValidateUtils.checkNotNullAndNotEmpty(pathArg, "No %s command sub-path specified", args[0]);
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java b/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
index 73349e583..7d13da89a 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
@@ -62,7 +62,6 @@ public class GitPgmCommand extends AbstractGitCommand {
 
                 if (argVal.startsWith("\"") && argVal.endsWith("\"")) {
                     args[i] = argVal.substring(1, argVal.length() - 1);
-                    argVal = args[i];
                 }
             }
 
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
index 8788b1876..df4c7fec8 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
@@ -78,7 +78,7 @@ public class PGPAuthorizedEntriesTracker
         this.keyFiles = GenericUtils.isEmpty(keys)
                 ? new ArrayList<>()
                 : keys.stream()
-                        .map(k -> new PGPPublicKeyFileWatcher(k))
+                        .map(PGPPublicKeyFileWatcher::new)
                         .collect(Collectors.toCollection(() -> new ArrayList<>(keys.size())));
     }
 
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
index f0d853e21..e8d2eeda7 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
@@ -117,12 +117,10 @@ public class PGPKeyPairResourceParser
 
                 Key key = PGPKeyLoader.loadPGPKey(stream, password);
                 keys = extractKeyPairs(resourceKey, key.getSubkeys());
-                key = null; // get rid of sensitive data a.s.a.p.
             } catch (IOException | GeneralSecurityException | PGPException | RuntimeException e) {
                 ResourceDecodeResult result = (passwordProvider != null)
                         ? passwordProvider.handleDecodeAttemptResult(session, resourceKey, retryCount, password, e)
                         : ResourceDecodeResult.TERMINATE;
-                password = null; // get rid of sensitive data a.s.a.p.
                 if (result == null) {
                     result = ResourceDecodeResult.TERMINATE;
                 }
@@ -150,7 +148,6 @@ public class PGPKeyPairResourceParser
 
             if (passwordProvider != null) {
                 passwordProvider.handleDecodeAttemptResult(session, resourceKey, retryCount, password, null);
-                password = null; // get rid of sensitive data a.s.a.p.
             }
 
             return keys;
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/client/AbstractScpClientCreator.java b/sshd-scp/src/main/java/org/apache/sshd/scp/client/AbstractScpClientCreator.java
index fa68bbe53..2f0f21a9f 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/client/AbstractScpClientCreator.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/client/AbstractScpClientCreator.java
@@ -37,7 +37,7 @@ public abstract class AbstractScpClientCreator extends AbstractLoggingBean imple
         this("");
     }
 
-    public AbstractScpClientCreator(String discriminator) {
+    protected AbstractScpClientCreator(String discriminator) {
         super(discriminator);
     }
 
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
index bcefee69f..0973df780 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
@@ -668,9 +668,7 @@ public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Sess
 
             ScpAckInfo ackInfo = sendAcknowledgedCommand(cmd);
             if (debugEnabled) {
-                if (debugEnabled) {
-                    log.debug("sendDir({})[{}] command='{}' ACK={}", this, path, cmd, ackInfo);
-                }
+                log.debug("sendDir({})[{}] command='{}' ACK={}", this, path, cmd, ackInfo);
             }
             validateAckReplyCode(cmd, path, ackInfo);
         }
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/LocalFileScpTargetStreamResolver.java b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/LocalFileScpTargetStreamResolver.java
index c04aa0492..a501a68f9 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/LocalFileScpTargetStreamResolver.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/LocalFileScpTargetStreamResolver.java
@@ -108,7 +108,7 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
         }
 
         if (log.isTraceEnabled()) {
-            log.trace("resolveTargetStream(" + name + "): " + file);
+            log.trace("resolveTargetStream({}): {}", name, file);
         }
 
         return opener.openWrite(session, file, length, perms, options);
@@ -119,7 +119,7 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
             Session session, String name, long length, Set<PosixFilePermission> perms, OutputStream stream)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("closeTargetStream(" + name + "): " + file);
+            log.trace("closeTargetStream({}): {}", name, file);
         }
 
         opener.closeWrite(session, file, length, perms, stream);
@@ -153,7 +153,7 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
             throws IOException {
         boolean traceEnabled = log.isTraceEnabled();
         if (traceEnabled) {
-            log.trace("updateFileProperties(" + name + ")[" + path + "] permissions: " + perms);
+            log.trace("updateFileProperties({})[{}] permissions: {}", name, path, perms);
         }
         IoUtils.setPermissions(path, perms);
 
@@ -162,8 +162,8 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
             FileTime lastModified = FileTime.from(time.getLastModifiedTime(), TimeUnit.MILLISECONDS);
             FileTime lastAccess = FileTime.from(time.getLastAccessTime(), TimeUnit.MILLISECONDS);
             if (traceEnabled) {
-                log.trace("updateFileProperties(" + name + ")[" + path + "] last-modified=" + lastModified + ", last-access="
-                          + lastAccess);
+                log.trace("updateFileProperties({})[{}] last-modified={}, last-access={}", name, path, lastModified,
+                        lastAccess);
             }
 
             view.setTimes(lastModified, lastAccess, null);
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
index 38552befa..daa48ab9f 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
@@ -122,9 +122,8 @@ public final class ScpIoUtils {
             long endTime = System.nanoTime();
             long nanosWait = endTime - startTime;
             if ((log != null) && log.isTraceEnabled()) {
-                log.trace("openCommandChannel(" + session + ")[" + cmd + "]"
-                          + " completed after " + nanosWait
-                          + " nanos out of " + waitTimeout.toNanos());
+                log.trace("openCommandChannel({})[{}] completed after {} nanos out of {}", session, cmd, nanosWait,
+                        waitTimeout.toNanos());
             }
 
             return channel;
@@ -132,11 +131,8 @@ public final class ScpIoUtils {
             long endTime = System.nanoTime();
             long nanosWait = endTime - startTime;
             if ((log != null) && log.isTraceEnabled()) {
-                log.trace("openCommandChannel(" + session + ")[" + cmd + "]"
-                          + " failed (" + e.getClass().getSimpleName() + ")"
-                          + " to complete after " + nanosWait
-                          + " nanos out of " + waitTimeout.toNanos()
-                          + ": " + e.getMessage());
+                log.trace("openCommandChannel({})[{}] failed after {} nanos out of {}: {}", session, cmd, nanosWait,
+                        waitTimeout.toNanos(), e.toString());
             }
 
             channel.close(false);
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/server/InputStreamReader.java b/sshd-scp/src/main/java/org/apache/sshd/scp/server/InputStreamReader.java
index c15801806..d50ca7ef3 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/server/InputStreamReader.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/server/InputStreamReader.java
@@ -53,7 +53,7 @@ import java.nio.charset.UnmappableCharacterException;
  * characters by either a default or a provided character converter. The default encoding is taken from the
  * "file.encoding" system property. {@code InputStreamReader} contains a buffer of bytes read from the source stream and
  * converts these into characters as needed. The buffer size is 8K.
- * 
+ *
  * @see OutputStreamWriter
  */
 public class InputStreamReader extends Reader {
@@ -74,7 +74,7 @@ public class InputStreamReader extends Reader {
      * Constructs a new {@code InputStreamReader} on the {@link InputStream} {@code in}. This constructor sets the
      * character converter to the encoding specified in the "file.encoding" property and falls back to ISO 8859_1
      * (ISO-Latin-1) if the property doesn't exist.
-     * 
+     *
      * @param in the input stream from which to read characters.
      */
     public InputStreamReader(InputStream in) {
@@ -90,7 +90,7 @@ public class InputStreamReader extends Reader {
      * Constructs a new InputStreamReader on the InputStream {@code in}. The character converter that is used to decode
      * bytes into characters is identified by name by {@code enc}. If the encoding cannot be found, an
      * UnsupportedEncodingException error is thrown.
-     * 
+     *
      * @param  in                           the InputStream from which to read characters.
      * @param  enc                          identifies the character converter to use.
      * @throws NullPointerException         if {@code enc} is {@code null}.
@@ -115,7 +115,7 @@ public class InputStreamReader extends Reader {
 
     /**
      * Constructs a new InputStreamReader on the InputStream {@code in} and CharsetDecoder {@code dec}.
-     * 
+     *
      * @param in  the source InputStream from which to read characters.
      * @param dec the CharsetDecoder used by the character conversion.
      */
@@ -129,7 +129,7 @@ public class InputStreamReader extends Reader {
 
     /**
      * Constructs a new InputStreamReader on the InputStream {@code in} and Charset {@code charset}.
-     * 
+     *
      * @param in      the source InputStream from which to read characters.
      * @param charset the Charset that defines the character converter
      */
@@ -144,7 +144,7 @@ public class InputStreamReader extends Reader {
 
     /**
      * Closes this reader. This implementation closes the source InputStream and releases all local storage.
-     * 
+     *
      * @throws IOException if an error occurs attempting to close this reader.
      */
     @Override
@@ -161,7 +161,7 @@ public class InputStreamReader extends Reader {
     /**
      * Returns the name of the encoding used to convert bytes into characters. The value {@code null} is returned if
      * this reader has been closed.
-     * 
+     *
      * @return the name of the character converter or {@code null} if this reader is closed.
      */
     public String getEncoding() {
@@ -175,7 +175,7 @@ public class InputStreamReader extends Reader {
      * Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0.
      * Returns -1 if the end of the reader has been reached. The byte value is either obtained from converting bytes in
      * this reader's buffer or by first filling the buffer from the source InputStream and then reading from the buffer.
-     * 
+     *
      * @return             the character read or -1 if the end of the reader has been reached.
      * @throws IOException if this reader is closed or some other I/O error occurs.
      */
@@ -191,7 +191,7 @@ public class InputStreamReader extends Reader {
                 pending = (char) -1;
                 return c;
             }
-            char buf[] = new char[2];
+            char[] buf = new char[2];
             int nb = read(buf, 0, 2);
             if (nb == 2) {
                 pending = buf[1];
@@ -209,7 +209,7 @@ public class InputStreamReader extends Reader {
      * character array {@code buf}. Returns the number of characters actually read or -1 if the end of the reader has
      * been reached. The bytes are either obtained from converting bytes in this reader's buffer or by first filling the
      * buffer from the source InputStream and then reading from the buffer.
-     * 
+     *
      * @param  buf                       the array to store the characters read.
      * @param  offset                    the initial position in {@code buf} to store the characters read from this
      *                                   reader.
@@ -308,7 +308,7 @@ public class InputStreamReader extends Reader {
      * {@code read()} will not block. If the result is {@code false} then this reader may or may not block when
      * {@code read()} is called. This implementation returns {@code true} if there are bytes available in the buffer or
      * the source stream has bytes available.
-     * 
+     *
      * @return             {@code true} if the receiver will not block when {@code read()} is called, {@code false} if
      *                     unknown or blocking will occur.
      * @throws IOException if this reader is closed or some other I/O error occurs.
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
index 5a487ed55..4bff81d54 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
@@ -77,7 +77,7 @@ public abstract class AbstractSftpClientExtension extends AbstractLoggingBean im
     protected void sendAndCheckExtendedCommandStatus(Buffer buffer) throws IOException {
         int reqId = sendExtendedCommand(buffer);
         if (log.isDebugEnabled()) {
-            log.debug("sendAndCheckExtendedCommandStatus(" + getName() + ") id=" + reqId);
+            log.debug("sendAndCheckExtendedCommandStatus({}) id={}", getName(), reqId);
         }
         checkStatus(receive(reqId));
     }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpClientDirectoryScanner.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpClientDirectoryScanner.java
index cb5287e82..b0fbbf166 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpClientDirectoryScanner.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpClientDirectoryScanner.java
@@ -97,7 +97,7 @@ public class SftpClientDirectoryScanner extends PathScanningMatcher {
                 ? Collections.emptyList()
                 : Collections.unmodifiableList(
                         includes.stream()
-                                .map(v -> SftpPathDirectoryScanner.adjustPattern(v))
+                                .map(SftpPathDirectoryScanner::adjustPattern)
                                 .collect(Collectors.toCollection(() -> new ArrayList<>(includes.size()))));
     }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
index 199664cc2..4ea058e69 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
@@ -794,7 +794,7 @@ public class SftpFileSystemProvider extends FileSystemProvider {
         try (SftpClient client = fsLink.getClient()) {
             String linkPath = client.readLink(l.toString());
             if (log.isDebugEnabled()) {
-                log.debug("readSymbolicLink({})[{}] {} => {}", fsLink, link, linkPath);
+                log.debug("readSymbolicLink({}) {} => {}", fsLink, link, linkPath);
             }
 
             return fsLink.getPath(linkPath);
@@ -1196,7 +1196,7 @@ public class SftpFileSystemProvider extends FileSystemProvider {
                     break;
                 default:
                     if (traceEnabled) {
-                        log.trace("attributesToPermissions(" + path + ") ignored " + p);
+                        log.trace("attributesToPermissions({}) ignored {}", path, p);
                     }
             }
         }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpPathDirectoryScanner.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpPathDirectoryScanner.java
index 6bc13dee0..ed2a79010 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpPathDirectoryScanner.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpPathDirectoryScanner.java
@@ -79,7 +79,7 @@ public class SftpPathDirectoryScanner extends DirectoryScanner {
                 ? Collections.emptyList()
                 : Collections.unmodifiableList(
                         includes.stream()
-                                .map(v -> adjustPattern(v))
+                                .map(SftpPathDirectoryScanner::adjustPattern)
                                 .collect(Collectors.toCollection(() -> new ArrayList<>(includes.size()))));
     }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
index 15a42c9a8..f0c1243db 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
@@ -493,7 +493,7 @@ public class DefaultSftpClient extends AbstractSftpClient {
 
         Map<String, ?> parsed = getParsedServerExtensions();
         Collection<String> extensions = ParserUtils.supportedExtensions(parsed);
-        List<Integer> availableVersions = Collections.emptyList();
+        List<Integer> availableVersions;
         if ((GenericUtils.size(extensions) > 0)
                 && extensions.contains(SftpConstants.EXT_VERSION_SELECT)) {
             Versions vers = MapEntryUtils.isEmpty(parsed)
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpDirEntryIterator.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpDirEntryIterator.java
index a8d2c644b..fea1a4289 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpDirEntryIterator.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpDirEntryIterator.java
@@ -141,7 +141,7 @@ public class SftpDirEntryIterator extends AbstractLoggingBean implements SftpCli
             Handle handle = getHandle();
             if ((handle instanceof Closeable) && isCloseOnFinished()) {
                 if (log.isDebugEnabled()) {
-                    log.debug("close(" + getPath() + ") handle=" + handle);
+                    log.debug("close({}) handle={}", getPath(), handle);
                 }
                 ((Closeable) handle).close();
             }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpInputStreamAsync.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpInputStreamAsync.java
index d52b005dd..8be006ff8 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpInputStreamAsync.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpInputStreamAsync.java
@@ -162,9 +162,7 @@ public class SftpInputStreamAsync extends InputStreamWithChannel implements Sftp
             throw new IOException("transferTo(" + getPath() + ") stream closed");
         }
 
-        long numXfered = doRead(Long.MAX_VALUE, buf -> {
-            out.write(buf.array(), buf.rpos(), buf.available());
-        });
+        long numXfered = doRead(Long.MAX_VALUE, buf -> out.write(buf.array(), buf.rpos(), buf.available()));
         if (log.isDebugEnabled()) {
             log.debug("transferTo({}) transferred {} bytes", this, numXfered);
         }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpOutputStreamAsync.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpOutputStreamAsync.java
index a9da91724..623f4a3f8 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpOutputStreamAsync.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpOutputStreamAsync.java
@@ -176,7 +176,7 @@ public class SftpOutputStreamAsync extends OutputStreamWithChannel implements Sf
                 log.debug("flush({}) processing ack #{}: {}", this, ackIndex, ack);
             }
 
-            ack = pendingWrites.removeFirst();
+            pendingWrites.removeFirst();
             client.checkResponseStatus(SftpConstants.SSH_FXP_WRITE, response);
         }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/SftpHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/SftpHelper.java
index a39415008..e14b9a55a 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/SftpHelper.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/SftpHelper.java
@@ -1003,15 +1003,15 @@ public final class SftpHelper {
         return mask;
     }
 
-    public static <B extends Buffer> B writeACLs(B buffer, int version, Collection<? extends AclEntry> acl) {
+    public static <B extends Buffer> B writeACLs(B buffer, int version, Collection<AclEntry> acl) {
         int lenPos = buffer.wpos();
         buffer.putUInt(0L); // length placeholder
-        buffer = encodeACLs(buffer, version, acl);
+        encodeACLs(buffer, version, acl);
         BufferUtils.updateLengthPlaceholder(buffer, lenPos);
         return buffer;
     }
 
-    public static <B extends Buffer> B encodeACLs(B buffer, int version, Collection<? extends AclEntry> acl) {
+    public static <B extends Buffer> B encodeACLs(B buffer, int version, Collection<AclEntry> acl) {
         Objects.requireNonNull(acl, "No ACL");
         if (version >= SftpConstants.SFTP_V6) {
             buffer.putUInt(0L); // TODO handle ACL flags
@@ -1021,7 +1021,7 @@ public final class SftpHelper {
         buffer.putInt(numEntries);
         if (numEntries > 0) {
             for (AclEntry e : acl) {
-                buffer = writeAclEntry(buffer, e);
+                writeAclEntry(buffer, e);
             }
         }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpEventListenerAdapter.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpEventListenerAdapter.java
index 43f2e0657..565807c5c 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpEventListenerAdapter.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpEventListenerAdapter.java
@@ -51,14 +51,14 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     @Override
     public void initialized(ServerSession session, int version) throws IOException {
         if (log.isDebugEnabled()) {
-            log.debug("initialized(" + session + ") version=" + version);
+            log.debug("initialized({}) version={}", session, version);
         }
     }
 
     @Override
     public void destroying(ServerSession session) throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("destroying(" + session + ")");
+            log.trace("destroying({})", session);
         }
     }
 
@@ -66,8 +66,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void opening(ServerSession session, String remoteHandle, Handle localHandle) throws IOException {
         if (log.isTraceEnabled()) {
             Path path = localHandle.getFile();
-            log.trace("opening(" + session + ")[" + remoteHandle + "] " + (Files.isDirectory(path) ? "directory" : "file") + " "
-                      + path);
+            log.trace("opening({})[{}] {} {}", session, remoteHandle, Files.isDirectory(path) ? "directory" : "file", path);
         }
     }
 
@@ -85,8 +84,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void open(ServerSession session, String remoteHandle, Handle localHandle) throws IOException {
         if (log.isTraceEnabled()) {
             Path path = localHandle.getFile();
-            log.trace("open(" + session + ")[" + remoteHandle + "] " + (Files.isDirectory(path) ? "directory" : "file") + " "
-                      + path);
+            log.trace("open({})[{}] {} {}", session, remoteHandle, Files.isDirectory(path) ? "directory" : "file", path);
         }
     }
 
@@ -103,12 +101,12 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             throws IOException {
         int numEntries = MapEntryUtils.size(entries);
         if (log.isDebugEnabled()) {
-            log.debug("read(" + session + ")[" + localHandle.getFile() + "] " + numEntries + " entries");
+            log.debug("read({})[{}] {} entries", session, localHandle.getFile(), numEntries);
         }
 
         if ((numEntries > 0) && log.isTraceEnabled()) {
             entries.forEach(
-                    (key, value) -> log.trace("read(" + session + ")[" + localHandle.getFile() + "] " + key + " - " + value));
+                    (key, value) -> log.trace("read({})[{}] {} - {}", session, localHandle.getFile(), key, value));
         }
     }
 
@@ -118,7 +116,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             long offset, byte[] data, int dataOffset, int dataLen)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("reading(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen);
+            log.trace("reading({})[{}] offset={}, requested={}", session, localHandle.getFile(), offset, dataLen);
         }
     }
 
@@ -129,9 +127,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("read(" + session + ")[" + localHandle.getFile() + "] offset=" + offset
-                      + ", requested=" + dataLen + ", read=" + readLen
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("read({})[{}] offset={}, requested={}, read={}{}", session, localHandle.getFile(), offset, dataLen,
+                    readLen, (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -141,7 +138,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             long offset, byte[] data, int dataOffset, int dataLen)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("write(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen);
+            log.trace("writing({})[{}] offset={}, requested={}", session, localHandle.getFile(), offset, dataLen);
         }
     }
 
@@ -151,8 +148,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("written(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("written({})[{}] offset={}, requested={}{}", session, localHandle.getFile(), offset, dataLen,
+                    (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -160,8 +157,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void blocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("blocking(" + session + ")[" + localHandle.getFile() + "]"
-                      + " offset=" + offset + ", length=" + length + ", mask=0x" + Integer.toHexString(mask));
+            log.trace("blocking({})[{}] offset={}, length={}, mask=0x{}", session, localHandle.getFile(), offset, length,
+                    Integer.toHexString(mask));
         }
     }
 
@@ -171,9 +168,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("blocked(" + session + ")[" + localHandle.getFile() + "]"
-                      + " offset=" + offset + ", length=" + length + ", mask=0x" + Integer.toHexString(mask)
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("blocked({})[{}] offset={}, length={}, mask=0x{}{}", session, localHandle.getFile(), offset, length,
+                    Integer.toHexString(mask), (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -181,7 +177,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void unblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("unblocking(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", length=" + length);
+            log.trace("unblocking({})[{}] offset={}, length={}", session, localHandle.getFile(), offset, length);
         }
     }
 
@@ -190,9 +186,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
             ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("unblocked(" + session + ")[" + localHandle.getFile() + "]"
-                      + " offset=" + offset + ", length=" + length
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("unblocked({})[{}] offset={}, length={}{}", session, localHandle.getFile(), offset, length,
+                    (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -200,8 +195,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void closing(ServerSession session, String remoteHandle, Handle localHandle) throws IOException {
         if (log.isTraceEnabled()) {
             Path path = localHandle.getFile();
-            log.trace("close(" + session + ")[" + remoteHandle + "] " + (Files.isDirectory(path) ? "directory" : "file") + " "
-                      + path);
+            log.trace("close({})[{}] {} {}", session, localHandle.getFile(), (Files.isDirectory(path) ? "directory" : "file"),
+                    path);
         }
     }
 
@@ -209,7 +204,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void closed(ServerSession session, String remoteHandle, Handle localHandle, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("closed({}) handle={}[{}], thrown={}", session, remoteHandle, localHandle.getFile(), thrown);
+            log.trace("closed({}) handle={}[{}]{}", session, remoteHandle, localHandle.getFile(),
+                    (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -217,7 +213,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void creating(ServerSession session, Path path, Map<String, ?> attrs)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("creating(" + session + ") " + (Files.isDirectory(path) ? "directory" : "file") + " " + path);
+            log.trace("creating({}) {} {}", session, (Files.isDirectory(path) ? "directory" : "file"), path);
         }
     }
 
@@ -225,8 +221,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void created(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("created(" + session + ") " + (Files.isDirectory(path) ? "directory" : "file") + " " + path
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("created({}) {} {}{}", session, (Files.isDirectory(path) ? "directory" : "file"), path,
+                    (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -234,7 +230,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void moving(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("moving(" + session + ")[" + opts + "]" + srcPath + " => " + dstPath);
+            log.trace("moving({})[{}] {} => {}", session, opts, srcPath, dstPath);
         }
     }
 
@@ -242,8 +238,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void moved(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("moved(" + session + ")[" + opts + "]" + srcPath + " => " + dstPath
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("moved({})[{}] {} => {}{}", session, opts, srcPath, dstPath, (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -251,7 +246,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void removing(ServerSession session, Path path, boolean isDirectory)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("removing(" + session + ")[dir=" + isDirectory + "] " + path);
+            log.trace("removing({})[dir={}] {}", session, isDirectory, path);
         }
     }
 
@@ -259,8 +254,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void removed(ServerSession session, Path path, boolean isDirectory, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("removed(" + session + ")[dir=" + isDirectory + "] " + path
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("removed({})[dir={}] {}{}", session, isDirectory, path, (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -268,7 +262,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void linking(ServerSession session, Path source, Path target, boolean symLink)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("linking(" + session + ")[" + symLink + "]" + source + " => " + target);
+            log.trace("linking({})[{}] {} => {}", session, symLink, source, target);
         }
     }
 
@@ -276,8 +270,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void linked(ServerSession session, Path source, Path target, boolean symLink, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("linked(" + session + ")[" + symLink + "]" + source + " => " + target
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("linked({})[{}] {} => {}{}", session, symLink, source, target, (thrown == null) ? "" : ": " + thrown);
         }
     }
 
@@ -285,7 +278,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void modifyingAttributes(ServerSession session, Path path, Map<String, ?> attrs)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("modifyingAttributes(" + session + ") " + path + ": " + attrs);
+            log.trace("modifyingAttributes({}) {}: {}", session, path, attrs);
         }
     }
 
@@ -293,8 +286,7 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe
     public void modifiedAttributes(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("modifiedAttributes(" + session + ") " + path
-                      + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage())));
+            log.trace("modifiedAttributes({}) {}{}", session, path, (thrown == null) ? "" : ": " + thrown);
         }
     }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
index 002ec3eac..425234e96 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
@@ -2307,13 +2307,11 @@ public abstract class AbstractSftpSubsystemHelper
             accessor.putRemoteFileName(this, f, buffer, longName, false);
 
             if (log.isTraceEnabled()) {
-                log.trace("writeDirEntry(" + session + ") id=" + id + ")[" + index + "] - "
-                          + shortName + " [" + longName + "]: " + attrs);
+                log.trace("writeDirEntry({} id={})[{}] - {} [{}]: {}", session, id, index, shortName, longName, attrs);
             }
         } else {
             if (log.isTraceEnabled()) {
-                log.trace("writeDirEntry(" + session + "(id=" + id + ")[" + index + "] - "
-                          + shortName + ": " + attrs);
+                log.trace("writeDirEntry({} id={})[{}] - {}: {}", session, id, index, shortName, attrs);
             }
         }
 
@@ -2420,20 +2418,18 @@ public abstract class AbstractSftpSubsystemHelper
     protected NavigableMap<String, Object> handleUnknownStatusFileAttributes(
             Path file, int flags, LinkOption... options)
             throws IOException {
-        UnsupportedAttributePolicy unsupportedAttributePolicy = getUnsupportedAttributePolicy();
-        switch (unsupportedAttributePolicy) {
+        UnsupportedAttributePolicy policy = getUnsupportedAttributePolicy();
+        switch (policy) {
             case Ignore:
                 break;
             case ThrowException:
                 throw new AccessDeniedException(file.toString(), file.toString(),
                         "Cannot determine existence for attributes of target");
             case Warn:
-                log.warn("handleUnknownStatusFileAttributes(" + getServerSession() + ")[" + file
-                         + "] cannot determine existence");
+                log.warn("handleUnknownStatusFileAttributes({})[{}] cannot determine existence", getServerSession(), file);
                 break;
             default:
-                log.warn("handleUnknownStatusFileAttributes(" + getServerSession() + ")[" + file + "] unknown policy: "
-                         + unsupportedAttributePolicy);
+                log.warn("handleUnknownStatusFileAttributes({})[{}] unknown policy: {}", getServerSession(), file, policy);
         }
 
         return getAttributes(file, flags, options);
@@ -2599,20 +2595,18 @@ public abstract class AbstractSftpSubsystemHelper
             log.trace("handleReadFileAttributesException(" + file + ")[" + view + "] details", e);
         }
 
-        UnsupportedAttributePolicy unsupportedAttributePolicy = getUnsupportedAttributePolicy();
-        switch (unsupportedAttributePolicy) {
+        UnsupportedAttributePolicy policy = getUnsupportedAttributePolicy();
+        switch (policy) {
             case Ignore:
                 break;
             case Warn:
-                log.warn("handleReadFileAttributesException(" + file + ")[" + view + "] " + e.getClass().getSimpleName() + ": "
-                         + e.getMessage());
+                log.warn("handleReadFileAttributesException({})[{}] {}", file, view, e.toString());
                 break;
             case ThrowException:
                 throw e;
             default:
-                log.warn("handleReadFileAttributesException(" + file + ")[" + view + "]"
-                         + " Unknown policy (" + unsupportedAttributePolicy + ")"
-                         + " for " + e.getClass().getSimpleName() + ": " + e.getMessage());
+                log.warn("handleReadFileAttributesException({})[{}] Unknown policy ({}) for {}", file, view, policy,
+                        e.toString());
         }
 
         return Collections.emptyNavigableMap();
@@ -2867,17 +2861,17 @@ public abstract class AbstractSftpSubsystemHelper
         }
 
         String attrsList = GenericUtils.join(attributes, ',');
-        UnsupportedAttributePolicy unsupportedAttributePolicy = getUnsupportedAttributePolicy();
-        switch (unsupportedAttributePolicy) {
+        UnsupportedAttributePolicy policy = getUnsupportedAttributePolicy();
+        switch (policy) {
             case Ignore:
                 break;
             case Warn:
-                log.warn("Unsupported attributes: " + attrsList);
+                log.warn("Unsupported attributes: {}", attrsList);
                 break;
             case ThrowException:
                 throw new UnsupportedOperationException("Unsupported attributes: " + attrsList);
             default:
-                log.warn("Unknown policy for attributes=" + attrsList + ": " + unsupportedAttributePolicy);
+                log.warn("Unknown policy ''{}'' for attributes={}", policy, attrsList);
         }
     }
 
@@ -2905,8 +2899,7 @@ public abstract class AbstractSftpSubsystemHelper
             Class<? extends Principal> principalType, String name, IOException e)
             throws IOException {
         if (log.isTraceEnabled()) {
-            log.trace("handleUserPrincipalLookupServiceException(" + principalType.getSimpleName() + "[" + name + "]) details",
-                    e);
+            log.trace("handleUserPrincipalLookupServiceException({})[{}] details", principalType.getSimpleName(), name, e);
         }
 
         /*
@@ -2915,19 +2908,18 @@ public abstract class AbstractSftpSubsystemHelper
          * "Where an implementation does not support any notion of group or user then this method always throws
          * UserPrincipalNotFoundException."
          */
-        UnsupportedAttributePolicy unsupportedAttributePolicy = getUnsupportedAttributePolicy();
-        switch (unsupportedAttributePolicy) {
+        UnsupportedAttributePolicy policy = getUnsupportedAttributePolicy();
+        switch (policy) {
             case Ignore:
                 break;
             case Warn:
-                log.warn("handleUserPrincipalLookupServiceException(" + principalType.getSimpleName() + "[" + name + "])"
-                         + " failed (" + e.getClass().getSimpleName() + "): " + e.getMessage());
+                log.warn("handleUserPrincipalLookupServiceException({})[{}] failed: {}", principalType.getSimpleName(), name,
+                        e.toString());
                 break;
             case ThrowException:
                 throw e;
             default:
-                log.warn("Unknown policy for principal=" + principalType.getSimpleName() + "[" + name + "]: "
-                         + unsupportedAttributePolicy);
+                log.warn("Unknown policy ''{}'' for principal={} [{}]", policy, principalType.getSimpleName(), name);
         }
     }
 
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
index bbfb8f5aa..f4c12ab36 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
@@ -1030,7 +1030,7 @@ public class SftpSubsystem
             boolean result = pendingFuture.cancel(true);
             // TODO consider waiting some reasonable (?) amount of time for cancellation
             if (debugEnabled) {
-                log.debug("destroy(" + session + ") - cancel pending future=" + result);
+                log.debug("destroy({}) - cancel pending future={}", session, result);
             }
         }
 
@@ -1040,7 +1040,7 @@ public class SftpSubsystem
         if ((executors != null) && (!executors.isShutdown())) {
             Collection<Runnable> runners = executors.shutdownNow();
             if (debugEnabled) {
-                log.debug("destroy(" + session + ") - shutdown executor service - runners count=" + runners.size());
+                log.debug("destroy({}) - shutdown executor service - runners count={}", session, runners.size());
             }
         }
         this.executorService = null;
@@ -1049,14 +1049,11 @@ public class SftpSubsystem
             fileSystem.close();
         } catch (UnsupportedOperationException e) {
             if (debugEnabled) {
-                log.debug("destroy(" + session + ") closing the file system is not supported");
+                log.debug("destroy({}) closing the file system is not supported", session);
             }
         } catch (IOException e) {
             if (debugEnabled) {
-                log.warn("destroy(" + session + ")"
-                         + " failed (" + e.getClass().getSimpleName() + ")"
-                         + " to close file system: " + e.getMessage(),
-                        e);
+                log.warn("destroy({}) failed to close the file system", session, e);
             }
         }
     }
diff --git a/sshd-sftp/src/test/java/org/apache/sshd/sftp/common/SftpUniversalOwnerAndGroupTest.java b/sshd-sftp/src/test/java/org/apache/sshd/sftp/common/SftpUniversalOwnerAndGroupTest.java
index dc662c3f4..83458c827 100644
--- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/common/SftpUniversalOwnerAndGroupTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/common/SftpUniversalOwnerAndGroupTest.java
@@ -42,7 +42,7 @@ public class SftpUniversalOwnerAndGroupTest extends JUnitTestSupport {
         for (SftpUniversalOwnerAndGroup value : SftpUniversalOwnerAndGroup.VALUES) {
             String name = value.getName();
             assertFalse(value.name() + ": empty name", GenericUtils.isEmpty(name));
-            assertTrue(value.name() + ": bad suffix", name.charAt(name.length() - 1) == '@');
+            assertEquals(value.name() + ": bad suffix", '@', name.charAt(name.length() - 1));
 
             for (int index = 0; index < name.length() - 1; index++) {
                 char ch = name.charAt(index);
diff --git a/sshd-spring-sftp/src/main/java/org/apache/sshd/sftp/spring/integration/ApacheSshdSftpSessionFactory.java b/sshd-spring-sftp/src/main/java/org/apache/sshd/sftp/spring/integration/ApacheSshdSftpSessionFactory.java
index f0e1dc73f..d39b17540 100644
--- a/sshd-spring-sftp/src/main/java/org/apache/sshd/sftp/spring/integration/ApacheSshdSftpSessionFactory.java
+++ b/sshd-spring-sftp/src/main/java/org/apache/sshd/sftp/spring/integration/ApacheSshdSftpSessionFactory.java
@@ -398,27 +398,20 @@ public class ApacheSshdSftpSessionFactory
                 SftpVersionSelector selector = getSftpVersionSelector();
                 SftpClientFactory sftpFactory = SftpClientFactory.instance();
                 SftpClient sftpClient = sftpFactory.createSftpClient(session, selector);
-                try {
-                    ClientSession sessionInstance = session;
-                    Session<DirEntry> result = sharedInstance
-                            ? new SpringSftpSession(sftpClient)
-                            : new SpringSftpSession(sftpClient, () -> {
-                                try {
-                                    sessionInstance.close();
-                                    return null;
-                                } catch (Exception e) {
-                                    return e;
-                                }
-                            });
-                    // avoid auto-close at finally clause
-                    sftpClient = null;
-                    session = null;
-                    return result;
-                } finally {
-                    if (sftpClient != null) {
-                        sftpClient.close();
-                    }
-                }
+                ClientSession sessionInstance = session;
+                Session<DirEntry> result = sharedInstance
+                        ? new SpringSftpSession(sftpClient)
+                        : new SpringSftpSession(sftpClient, () -> {
+                            try {
+                                sessionInstance.close();
+                                return null;
+                            } catch (Exception e) {
+                                return e;
+                            }
+                        });
+                // avoid auto-close at finally clause
+                session = null;
+                return result;
             } finally {
                 if (session != null) {
                     try {
@@ -523,7 +516,7 @@ public class ApacheSshdSftpSessionFactory
         }
 
         if (debugEnabled) {
-            log.debug("authenticateClientSession({}) authenticate - timeout=", session, timeout);
+            log.debug("authenticateClientSession({}) authenticate - timeout={}", session, timeout);
         }
         session.auth().verify(timeout);
         return session;