Skip to content

Commit

Permalink
Reuse IOUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Feb 23, 2025
1 parent 2ac0e56 commit 26d2132
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.time.Duration;
import java.util.Objects;

import org.apache.commons.io.IOUtils;

/**
* The DatagramSocketClient provides the basic operations that are required of client objects accessing datagram 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
Expand Down Expand Up @@ -89,9 +91,7 @@ protected DatagramSocket checkOpen() {
*/
@Override
public void close() {
if (_socket_ != null) {
_socket_.close();
}
IOUtils.closeQuietly(_socket_); // DatagramSocket#close() doesn't throw in its signature.
_socket_ = null;
_isOpen_ = false;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/apache/commons/net/bsd/RExecClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ InputStream createErrorStream() throws IOException {
*/
@Override
public void disconnect() throws IOException {
if (_errorStream_ != null) {
_errorStream_.close();
}
IOUtils.close(_errorStream_);
_errorStream_ = null;
super.disconnect();
}
Expand Down

0 comments on commit 26d2132

Please sign in to comment.