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
commit 2341e8766ea6cbdb7658184d0e336b93953c4eb4 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Feb 15 16:17:25 2025 -0500 Reuse IOUtils --- .../java/org/apache/commons/net/SocketClient.java | 29 ++++------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/apache/commons/net/SocketClient.java b/src/main/java/org/apache/commons/net/SocketClient.java index b403019c..a2d340d3 100644 --- a/src/main/java/org/apache/commons/net/SocketClient.java +++ b/src/main/java/org/apache/commons/net/SocketClient.java @@ -17,7 +17,6 @@ package org.apache.commons.net; -import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -32,6 +31,8 @@ import java.util.Objects; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; +import org.apache.commons.io.IOUtils; + /** * The SocketClient provides the basic operations that are required of client objects accessing sockets. It is meant to be subclassed to avoid having to rewrite * the same code over and over again to open a socket, close a socket, set timeouts, etc. Of special note is the {@link #setSocketFactory setSocketFactory } @@ -195,26 +196,6 @@ public abstract class SocketClient { return Objects.requireNonNull(_output_, "OutputStream"); } - private void closeQuietly(final Closeable close) { - if (close != null) { - try { - close.close(); - } catch (final IOException e) { - // Ignored - } - } - } - - private void closeQuietly(final Socket socket) { - if (socket != null) { - try { - socket.close(); - } catch (final IOException e) { - // Ignored - } - } - } - /** * Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port. Before returning, * {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. @@ -323,9 +304,9 @@ public abstract class SocketClient { */ @SuppressWarnings("unused") // subclasses may throw IOException public void disconnect() throws IOException { - closeQuietly(_socket_); - closeQuietly(_input_); - closeQuietly(_output_); + IOUtils.closeQuietly(_socket_); + IOUtils.closeQuietly(_input_); + IOUtils.closeQuietly(_output_); _socket_ = null; _hostname_ = null; _input_ = null;