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/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d3cf213 Use Java 6 API for exception construction
5d3cf213 is described below

commit 5d3cf2135ae91cab884d2c8e2cce8f96e49eb9a1
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Feb 15 13:51:22 2025 -0500

    Use Java 6 API for exception construction
---
 src/main/java/org/apache/commons/net/ftp/FTP.java                | 4 +---
 src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java      | 4 +---
 src/main/java/org/apache/commons/net/io/CopyStreamException.java | 3 +--
 src/main/java/org/apache/commons/net/util/SSLContextUtils.java   | 4 +---
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/ftp/FTP.java 
b/src/main/java/org/apache/commons/net/ftp/FTP.java
index d49534a5..65a23157 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTP.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTP.java
@@ -306,9 +306,7 @@ public class FTP extends SocketClient {
                     getReply();
                 }
             } catch (final SocketTimeoutException e) {
-                final IOException ioe = new IOException("Timed out waiting for 
initial connect reply");
-                ioe.initCause(e);
-                throw ioe;
+                throw new IOException("Timed out waiting for initial connect 
reply", e);
             } finally {
                 _socket_.setSoTimeout(original);
             }
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java 
b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
index b16ce591..644f5061 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
@@ -172,9 +172,7 @@ public class FTPHTTPClient extends FTPClient {
         try {
             socketIsReader = tunnelHandshake(host, port, _input_, _output_);
         } catch (final Exception e) {
-            final IOException ioe = new IOException("Could not connect to " + 
host + " using port " + port);
-            ioe.initCause(e);
-            throw ioe;
+            throw new IOException("Could not connect to " + host + " using 
port " + port, e);
         }
         super._connectAction_(socketIsReader);
     }
diff --git a/src/main/java/org/apache/commons/net/io/CopyStreamException.java 
b/src/main/java/org/apache/commons/net/io/CopyStreamException.java
index 72fc7c9e..2f602680 100644
--- a/src/main/java/org/apache/commons/net/io/CopyStreamException.java
+++ b/src/main/java/org/apache/commons/net/io/CopyStreamException.java
@@ -41,8 +41,7 @@ public class CopyStreamException extends IOException {
      * @param exception        The IOException thrown during a copy operation.
      */
     public CopyStreamException(final String message, final long 
bytesTransferred, final IOException exception) {
-        super(message);
-        initCause(exception); // merge this into super() call once we need 1.6+
+        super(message, exception);
         totalBytesTransferred = bytesTransferred;
     }
 
diff --git a/src/main/java/org/apache/commons/net/util/SSLContextUtils.java 
b/src/main/java/org/apache/commons/net/util/SSLContextUtils.java
index 5a07a0bf..49d7686e 100644
--- a/src/main/java/org/apache/commons/net/util/SSLContextUtils.java
+++ b/src/main/java/org/apache/commons/net/util/SSLContextUtils.java
@@ -60,9 +60,7 @@ public class SSLContextUtils {
             ctx = SSLContext.getInstance(protocol);
             ctx.init(keyManagers, trustManagers, /* SecureRandom */ null);
         } catch (final GeneralSecurityException e) {
-            final IOException ioe = new IOException("Could not initialize SSL 
context");
-            ioe.initCause(e);
-            throw ioe;
+            throw new IOException("Could not initialize SSL context", e);
         }
         return ctx;
     }

Reply via email to