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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2e2555e93 Throw more appropriate RuntimeException subclasses instead 
of RuntimeException.
2e2555e93 is described below

commit 2e2555e930da7691e6e80f6eef5aca6b05217938
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Jul 6 08:12:31 2023 -0400

    Throw more appropriate RuntimeException subclasses instead of
    RuntimeException.
    
    - RuntimeException -> IllegalArgumentException
    - RuntimeException -> IllegalStateException
    - IOException (checked) -> UncheckedIOException
    - CloneNotSupportedException (checked) -> UnsupportedOperationException
    (unchecked)
---
 .../sshd/client/auth/password/PasswordIdentityProvider.java       | 2 +-
 .../org/apache/sshd/client/config/hosts/HostPatternValue.java     | 5 +++--
 .../org/apache/sshd/client/config/hosts/KnownHostHashValue.java   | 8 +++++---
 .../sshd/client/config/keys/LazyClientKeyIdentityProvider.java    | 4 ++--
 .../src/main/java/org/apache/sshd/common/cipher/ECCurves.java     | 7 ++++---
 .../common/config/keys/loader/PrivateKeyEncryptionContext.java    | 2 +-
 .../apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java | 6 ++----
 .../org/apache/sshd/common/keyprovider/KeyIdentityProvider.java   | 4 ++--
 .../apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java  | 4 ++--
 .../main/java/org/apache/sshd/common/util/io/der/ASN1Object.java  | 2 +-
 .../java/org/apache/sshd/common/util/security/SecurityUtils.java  | 6 +++---
 .../bouncycastle/BouncyCastleSecurityProviderRegistrar.java       | 2 +-
 .../util/security/eddsa/EdDSASecurityProviderRegistrar.java       | 2 +-
 .../org/apache/sshd/common/util/threads/SshdThreadFactory.java    | 3 +--
 .../org/apache/sshd/agent/common/DefaultAgentForwardSupport.java  | 4 +++-
 .../src/main/java/org/apache/sshd/agent/unix/AprLibrary.java      | 2 +-
 .../org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java     | 4 +++-
 .../apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java | 4 ++--
 .../client/channel/exit/AbstractChannelExitRequestHandler.java    | 3 +--
 .../main/java/org/apache/sshd/common/channel/AbstractChannel.java | 2 +-
 .../apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java   | 4 ++--
 .../org/apache/sshd/common/session/helpers/SessionHelper.java     | 6 +++---
 .../apache/sshd/server/auth/keyboard/InteractiveChallenge.java    | 2 +-
 .../java/org/apache/sshd/server/auth/keyboard/PromptEntry.java    | 2 +-
 .../src/main/java/org/apache/sshd/server/shell/ProcessShell.java  | 5 ++---
 .../src/main/java/org/apache/sshd/scp/common/ScpLocation.java     | 2 +-
 .../main/java/org/apache/sshd/scp/server/ScpCommandFactory.java   | 2 +-
 .../client/extensions/openssh/OpenSSHLimitsExtensionInfo.java     | 2 +-
 .../sftp/client/extensions/openssh/OpenSSHStatExtensionInfo.java  | 2 +-
 .../org/apache/sshd/sftp/client/impl/SftpDirEntryIterator.java    | 3 ++-
 .../apache/sshd/sftp/common/extensions/AclSupportedParser.java    | 2 +-
 .../apache/sshd/sftp/common/extensions/FilenameCharsetParser.java | 2 +-
 .../org/apache/sshd/sftp/common/extensions/NewlineParser.java     | 2 +-
 .../sshd/sftp/common/extensions/SpaceAvailableExtensionInfo.java  | 2 +-
 .../common/extensions/openssh/AbstractOpenSSHExtensionParser.java | 2 +-
 35 files changed, 60 insertions(+), 56 deletions(-)

diff --git 
a/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
 
b/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
index 90db5c93a..956891346 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
@@ -169,7 +169,7 @@ public interface PasswordIdentityProvider {
                             try {
                                 return p.loadPasswords(session);
                             } catch (IOException | GeneralSecurityException e) 
{
-                                throw new RuntimeException(e);
+                                throw new IllegalArgumentException(e);
                             }
                         });
         return GenericUtils.multiIterableSuppliers(passwordSuppliers);
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
 
b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
index 7629d582c..8b3546528 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
@@ -88,8 +88,9 @@ public class HostPatternValue {
         try {
             KnownHostHashValue.appendHostPattern(sb, purePattern, portValue);
         } catch (IOException e) {
-            throw new RuntimeException("Unexpected (" + 
e.getClass().getSimpleName() + ") failure"
-                                       + " to append host pattern of " + 
purePattern + ":" + portValue + ": " + e.getMessage(),
+            throw new IllegalStateException("Unexpected (" + 
e.getClass().getSimpleName() + ") failure"
+                                            + " to append host pattern of " + 
purePattern + ":" + portValue + ": "
+                                            + e.getMessage(),
                     e);
         }
 
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 2e6bb7436..cb6e4f90f 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
@@ -20,6 +20,7 @@
 package org.apache.sshd.client.config.hosts;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Base64;
@@ -142,9 +143,10 @@ public class KnownHostHashValue {
         try {
             return appendHostPattern(new StringBuilder(host.length() + 8 /* 
port if necessary */), host, port).toString();
         } catch (IOException e) {
-            throw new RuntimeException("Unexpected (" + 
e.getClass().getSimpleName() + ") failure"
-                                       + " to generate host pattern of " + 
host + ":"
-                                       + port + ": " + e.getMessage(),
+            // StringBuilder does not throw IOException so this can't happen
+            throw new UncheckedIOException("Unexpected (" + 
e.getClass().getSimpleName() + ") failure"
+                                           + " to generate host pattern of " + 
host + ":"
+                                           + port + ": " + e.getMessage(),
                     e);
         }
     }
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
 
b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
index 3658c5dd0..a38fdf038 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
@@ -106,8 +106,8 @@ public class LazyClientKeyIdentityProvider
                     try {
                         ids = loadClientIdentities(session, l);
                     } catch (IOException | GeneralSecurityException e) {
-                        throw new RuntimeException("Failed (" + 
e.getClass().getSimpleName() + ")"
-                                                   + " to load key from " + 
l.getName() + ": " + e.getMessage(),
+                        throw new IllegalStateException("Failed (" + 
e.getClass().getSimpleName() + ")"
+                                                        + " to load key from " 
+ l.getName() + ": " + e.getMessage(),
                                 e);
                     }
 
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java 
b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
index 12f9e5e5a..b3f98bc05 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
@@ -23,6 +23,7 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.StreamCorruptedException;
+import java.io.UncheckedIOException;
 import java.math.BigInteger;
 import java.security.interfaces.ECKey;
 import java.security.spec.ECField;
@@ -538,9 +539,9 @@ public enum ECCurves implements KeyTypeIndicator, 
KeySizeIndicator, NamedResourc
                 writeECPoint(baos, curveName, p);
                 return baos.toByteArray();
             } catch (IOException e) {
-                throw new RuntimeException("ecPointToOctetString(" + curveName 
+ ")"
-                                           + " failed (" + 
e.getClass().getSimpleName() + ")"
-                                           + " to write data: " + 
e.getMessage(),
+                throw new UncheckedIOException("ecPointToOctetString(" + 
curveName + ")"
+                                               + " failed (" + 
e.getClass().getSimpleName() + ")"
+                                               + " to write data: " + 
e.getMessage(),
                         e);
             }
         }
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
index 78efb2e63..5a3e32d36 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
@@ -208,7 +208,7 @@ public class PrivateKeyEncryptionContext implements 
MutablePassword, Cloneable {
             }
             return copy;
         } catch (CloneNotSupportedException e) { // unexpected
-            throw new RuntimeException("Failed to clone: " + toString());
+            throw new UnsupportedOperationException("Failed to clone: " + 
toString());
         }
     }
 
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
index 56a62bc70..84b546ed2 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
@@ -695,10 +695,8 @@ public class BCrypt {
                   }
               }
           }
-      } catch (DigestException e) {
-          throw new RuntimeException(e);
-      } catch (NoSuchAlgorithmException e) {
-          throw new RuntimeException(e);
+      } catch (DigestException | NoSuchAlgorithmException e) {
+          throw new IllegalArgumentException(e);
       }
   }
 
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 4fa3cefa4..fd7059573 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
@@ -145,8 +145,8 @@ public interface KeyIdentityProvider {
             try {
                 return p.loadKeys(session);
             } catch (IOException | GeneralSecurityException e) {
-                throw new RuntimeException("Unexpected " + 
e.getClass().getSimpleName() + ")"
-                                           + " keys loading exception: " + 
e.getMessage(),
+                throw new IllegalArgumentException("Unexpected " + 
e.getClass().getSimpleName() + ")"
+                                                   + " keys loading exception: 
" + e.getMessage(),
                         e);
             }
         } else {
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
index 917f2e6c6..ab5a8c0d3 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
@@ -76,8 +76,8 @@ public class MultiKeyIdentityIterator implements 
Iterator<KeyPair>, SessionConte
             try {
                 keys = (p == null) ? null : p.loadKeys(session);
             } catch (IOException | GeneralSecurityException e) {
-                throw new RuntimeException("Unexpected " + 
e.getClass().getSimpleName() + ")"
-                                           + " keys loading exception: " + 
e.getMessage(),
+                throw new IllegalArgumentException("Unexpected " + 
e.getClass().getSimpleName() + ")"
+                                                   + " keys loading exception: 
" + e.getMessage(),
                         e);
             }
             currentProvider = (keys == null) ? null : keys.iterator();
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Object.java 
b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Object.java
index 5ef8338ac..c5f9e0241 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Object.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Object.java
@@ -321,7 +321,7 @@ public class ASN1Object implements Serializable, Cloneable {
             }
             return cpy;
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException("Unexpected clone failure: " + 
e.getMessage(), e);
+            throw new UnsupportedOperationException("Unexpected clone failure: 
" + e.getMessage(), e);
         }
     }
 
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 3214b6e41..6ce12254d 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
@@ -439,7 +439,7 @@ public final class SecurityUtils {
                         } else if (e instanceof Error) {
                             throw (Error) e;
                         } else {
-                            throw new RuntimeException(e);
+                            throw new IllegalStateException(e);
                         }
                     }
 
@@ -489,7 +489,7 @@ public final class SecurityUtils {
                 Logger logger = LoggerFactory.getLogger(SecurityUtils.class);
                 logger.error("Failed {} to register {} as a JCE provider: {}",
                         t.getClass().getSimpleName(), name, t.getMessage());
-                throw new RuntimeException("Failed to register " + name + " as 
a JCE provider", t);
+                throw new IllegalArgumentException("Failed to register " + 
name + " as a JCE provider", t);
             }
         }
 
@@ -737,7 +737,7 @@ public final class SecurityUtils {
             } else if (e instanceof Error) {
                 throw (Error) e;
             } else {
-                throw new RuntimeException(e);
+                throw new IllegalArgumentException(e);
             }
         }
     }
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java
index 33c6a6cb6..dd04668f6 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java
@@ -67,7 +67,7 @@ public class BouncyCastleSecurityProviderRegistrar extends 
AbstractSecurityProvi
                 throw (RuntimeException) e;
             }
 
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java
index 94355ce73..3aada0722 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java
@@ -64,7 +64,7 @@ public class EdDSASecurityProviderRegistrar extends 
AbstractSecurityProviderRegi
                 throw (RuntimeException) e;
             }
 
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/SshdThreadFactory.java
 
b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/SshdThreadFactory.java
index ec1dd5c11..25389e3a7 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/SshdThreadFactory.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/SshdThreadFactory.java
@@ -58,9 +58,8 @@ public class SshdThreadFactory extends AbstractLoggingBean 
implements ThreadFact
             Exception err = e.getException();
             if (err instanceof RuntimeException) {
                 throw (RuntimeException) err;
-            } else {
-                throw new RuntimeException(err);
             }
+            throw new IllegalStateException(err);
         }
 
         if (!t.isDaemon()) {
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java
 
b/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java
index 1c5cadd88..e72bd1850 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java
@@ -20,6 +20,7 @@
 package org.apache.sshd.agent.common;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -97,7 +98,8 @@ public class DefaultAgentForwardSupport extends 
AbstractCloseable implements Age
         try {
             close();
         } catch (IOException e) {
-            throw new RuntimeException("Failed (" + 
e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(), e);
+            throw new UncheckedIOException("Failed (" + 
e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(),
+                    e);
         }
         super.doCloseImmediately();
     }
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 505b99298..3defa6b00 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
@@ -59,7 +59,7 @@ public final class AprLibrary {
         } catch (RuntimeException e) {
             throw e;
         } catch (Throwable e) {
-            throw new RuntimeException("Error loading Apache Portable Runtime 
(APR).", e);
+            throw new IllegalStateException("Error loading Apache Portable 
Runtime (APR).", e);
         }
         pool = Pool.create(0);
     }
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
index 99c222727..376dfc048 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
@@ -20,6 +20,7 @@ package org.apache.sshd.client.auth.pubkey;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.security.KeyPair;
 import java.security.PublicKey;
 import java.security.spec.InvalidKeySpecException;
@@ -494,7 +495,8 @@ public class UserAuthPublicKey extends AbstractUserAuth 
implements SignatureFact
         try {
             releaseKeys();
         } catch (IOException e) {
-            throw new RuntimeException("Failed (" + 
e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(), e);
+            throw new UncheckedIOException("Failed (" + 
e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(),
+                    e);
         }
 
         super.destroy(); // for logging
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
index 72ccea6de..762efd128 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
@@ -98,8 +98,8 @@ public class UserAuthPublicKeyIterator extends 
AbstractKeyPairIterator<PublicKey
                         KeyIdentityProvider sessionKeysProvider = 
ClientSession.providerOf(session);
                         keysHolder.set(sessionKeysProvider.loadKeys(session));
                     } catch (IOException | GeneralSecurityException e) {
-                        throw new RuntimeException("Unexpected " + 
e.getClass().getSimpleName() + ")"
-                                                   + " keys loading exception: 
" + e.getMessage(),
+                        throw new IllegalArgumentException("Unexpected " + 
e.getClass().getSimpleName() + ")"
+                                                           + " keys loading 
exception: " + e.getMessage(),
                                 e);
                     }
                 }
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java
index 03ace94c5..6346de393 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java
@@ -105,9 +105,8 @@ public abstract class AbstractChannelExitRequestHandler<V> 
extends AbstractChann
                     channel, request, e.getClass().getSimpleName(), event, 
e.getMessage(), e);
             if (e instanceof RuntimeException) {
                 throw (RuntimeException) e;
-            } else {
-                throw new RuntimeException(e);
             }
+            throw new IllegalArgumentException(e);
         }
     }
 
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 202ef8fd2..077de9977 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
@@ -411,7 +411,7 @@ public abstract class AbstractChannel extends 
AbstractInnerCloseable implements
         } catch (Error | RuntimeException err) {
             throw err;
         } catch (Throwable err) {
-            throw new RuntimeException(err);
+            throw new IllegalStateException(err);
         }
     }
 
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 58abd27c5..80fd00e8d 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
@@ -73,7 +73,7 @@ public enum BuiltinIoServiceFactoryFactories implements 
NamedFactory<IoServiceFa
             try {
                 return (Class) Class.forName(factoryClassName, true, 
Thread.currentThread().getContextClassLoader());
             } catch (ClassNotFoundException e1) {
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             }
         }
     }
@@ -91,7 +91,7 @@ public enum BuiltinIoServiceFactoryFactories implements 
NamedFactory<IoServiceFa
         } catch (RuntimeException | Error e) {
             throw e;
         } catch (Throwable e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 74c0d886a..267e9bed4 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -1077,7 +1077,7 @@ public abstract class SessionHelper extends 
AbstractKexFactoryManager implements
             } else if (err instanceof Error) {
                 throw (Error) err;
             } else {
-                throw new RuntimeException(err);
+                throw new IllegalArgumentException(err);
             }
         }
     }
@@ -1104,7 +1104,7 @@ public abstract class SessionHelper extends 
AbstractKexFactoryManager implements
             } else if (err instanceof Error) {
                 throw (Error) err;
             } else {
-                throw new RuntimeException(err);
+                throw new IllegalArgumentException(err);
             }
         }
     }
@@ -1133,7 +1133,7 @@ public abstract class SessionHelper extends 
AbstractKexFactoryManager implements
             } else if (err instanceof Error) {
                 throw (Error) err;
             } else {
-                throw new RuntimeException(err);
+                throw new IllegalArgumentException(err);
             }
         }
     }
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/InteractiveChallenge.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/InteractiveChallenge.java
index 6c64a29e9..15142fe8f 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/InteractiveChallenge.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/InteractiveChallenge.java
@@ -118,7 +118,7 @@ public class InteractiveChallenge implements Cloneable {
             }
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException("Failed to clone " + toString() + ": " 
+ e.getMessage(), e);
+            throw new UnsupportedOperationException("Failed to clone " + 
toString() + ": " + e.getMessage(), e);
         }
     }
 
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/PromptEntry.java 
b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/PromptEntry.java
index f8dab48ff..b12adbd2c 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/PromptEntry.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/PromptEntry.java
@@ -90,7 +90,7 @@ public class PromptEntry implements Serializable, Cloneable {
         try {
             return getClass().cast(super.clone());
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException("Failed to clone " + toString() + ": " 
+ e.getMessage(), e);
+            throw new UnsupportedOperationException("Failed to clone " + 
toString() + ": " + e.getMessage(), e);
         }
     }
 
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java 
b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
index 32a93ccf8..496ab0a9f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
@@ -163,11 +163,10 @@ public class ProcessShell extends AbstractLoggingBean 
implements InvertedShell {
             try {
                 return process.waitFor();
             } catch (InterruptedException e) {
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             }
-        } else {
-            return process.exitValue();
         }
+        return process.exitValue();
     }
 
     @Override
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpLocation.java 
b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpLocation.java
index c5ed07bf8..d3eeb7a97 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpLocation.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpLocation.java
@@ -176,7 +176,7 @@ public class ScpLocation implements MutableUserHolder, 
Serializable, Cloneable {
         try {
             return getClass().cast(super.clone());
         } catch (CloneNotSupportedException e) { // unexpected
-            throw new RuntimeException("Failed to clone " + toString(), e);
+            throw new UnsupportedOperationException("Failed to clone " + 
toString(), e);
         }
     }
 
diff --git 
a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java 
b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
index 9cb791f59..bca5d7773 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
@@ -289,7 +289,7 @@ public class ScpCommandFactory
             other.listenerProxy = 
EventListenerUtils.proxyWrapper(ScpTransferEventListener.class, 
other.listeners);
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e); // un-expected...
+            throw new UnsupportedOperationException(e); // un-expected...
         }
     }
 }
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHLimitsExtensionInfo.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHLimitsExtensionInfo.java
index f36590278..e2366cafb 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHLimitsExtensionInfo.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHLimitsExtensionInfo.java
@@ -100,7 +100,7 @@ public class OpenSSHLimitsExtensionInfo implements 
Cloneable {
         try {
             return getClass().cast(super.clone());
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException("Failed to close " + toString() + ": " 
+ e.getMessage());
+            throw new UnsupportedOperationException("Failed to close " + 
toString() + ": " + e.getMessage());
         }
     }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHStatExtensionInfo.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHStatExtensionInfo.java
index cc610b0da..01b384305 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHStatExtensionInfo.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/openssh/OpenSSHStatExtensionInfo.java
@@ -98,7 +98,7 @@ public class OpenSSHStatExtensionInfo implements Cloneable {
         try {
             return getClass().cast(super.clone());
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException("Failed to close " + toString() + ": " 
+ e.getMessage());
+            throw new UnsupportedOperationException("Failed to close " + 
toString() + ": " + e.getMessage());
         }
     }
 
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 fea1a4289..9c5011b10 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
@@ -20,6 +20,7 @@ package org.apache.sshd.sftp.client.impl;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.channels.Channel;
 import java.util.Iterator;
 import java.util.List;
@@ -177,7 +178,7 @@ public class SftpDirEntryIterator extends 
AbstractLoggingBean implements SftpCli
                 debug("{} while close handle={} due to {} [{}]: {}",
                         t.getClass().getSimpleName(), handle, 
e.getClass().getSimpleName(), e.getMessage(), t);
             }
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/AclSupportedParser.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/AclSupportedParser.java
index f46266494..f245798ba 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/AclSupportedParser.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/AclSupportedParser.java
@@ -99,7 +99,7 @@ public class AclSupportedParser extends 
AbstractParser<AclCapabilities> {
             try {
                 return getClass().cast(super.clone());
             } catch (CloneNotSupportedException e) {
-                throw new RuntimeException("Failed to clone " + toString() + 
": " + e.getMessage(), e);
+                throw new UnsupportedOperationException("Failed to clone " + 
toString() + ": " + e.getMessage(), e);
             }
         }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/FilenameCharsetParser.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/FilenameCharsetParser.java
index 2bed4da0b..89252d7a3 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/FilenameCharsetParser.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/FilenameCharsetParser.java
@@ -64,7 +64,7 @@ public class FilenameCharsetParser extends 
AbstractParser<FilenameCharset> {
             try {
                 return getClass().cast(super.clone());
             } catch (CloneNotSupportedException e) {
-                throw new RuntimeException("Failed to clone " + toString() + 
": " + e.getMessage(), e);
+                throw new UnsupportedOperationException("Failed to clone " + 
toString() + ": " + e.getMessage(), e);
             }
         }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/NewlineParser.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/NewlineParser.java
index c5d5e7110..148b89d5f 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/NewlineParser.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/NewlineParser.java
@@ -84,7 +84,7 @@ public class NewlineParser extends AbstractParser<Newline> {
             try {
                 return getClass().cast(super.clone());
             } catch (CloneNotSupportedException e) {
-                throw new RuntimeException("Failed to clone " + toString() + 
": " + e.getMessage(), e);
+                throw new UnsupportedOperationException("Failed to clone " + 
toString() + ": " + e.getMessage(), e);
             }
         }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/SpaceAvailableExtensionInfo.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/SpaceAvailableExtensionInfo.java
index abc7fe736..ef79e2921 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/SpaceAvailableExtensionInfo.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/SpaceAvailableExtensionInfo.java
@@ -89,7 +89,7 @@ public class SpaceAvailableExtensionInfo implements Cloneable 
{
         try {
             return getClass().cast(super.clone());
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException("Failed to close " + toString() + ": " 
+ e.getMessage());
+            throw new UnsupportedOperationException("Failed to close " + 
toString() + ": " + e.getMessage());
         }
     }
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/openssh/AbstractOpenSSHExtensionParser.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/openssh/AbstractOpenSSHExtensionParser.java
index 45833a9a2..710d9c709 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/openssh/AbstractOpenSSHExtensionParser.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/common/extensions/openssh/AbstractOpenSSHExtensionParser.java
@@ -88,7 +88,7 @@ public abstract class AbstractOpenSSHExtensionParser extends 
AbstractParser<Open
             try {
                 return getClass().cast(super.clone());
             } catch (CloneNotSupportedException e) {
-                throw new RuntimeException("Unexpected clone exception " + 
toString() + ": " + e.getMessage());
+                throw new UnsupportedOperationException("Unexpected clone 
exception " + toString() + ": " + e.getMessage());
             }
         }
 


Reply via email to