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
commit eea2ecaadd7a70001d4df5842963dcbfb8f32ec2 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu May 30 11:02:26 2024 -0400 Use try-with resources --- .../common/forward/ConcurrentConnectionTest.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/ConcurrentConnectionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/ConcurrentConnectionTest.java index 65af56e46..ec9c24968 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/forward/ConcurrentConnectionTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/ConcurrentConnectionTest.java @@ -234,23 +234,23 @@ public class ConcurrentConnectionTest extends BaseTestSupport { throws Exception { outputDebugMessage("readInLoop(port=%d)", serverPort); - final Socket s = new Socket(); - s.setSoTimeout(SO_TIMEOUT); + try (Socket s = new Socket()) { + s.setSoTimeout(SO_TIMEOUT); - barrier.await(); + barrier.await(); - s.connect(new InetSocketAddress(TEST_LOCALHOST, serverPort)); + s.connect(new InetSocketAddress(TEST_LOCALHOST, serverPort)); - s.getOutputStream().write(PAYLOAD_TO_SERVER); + s.getOutputStream().write(PAYLOAD_TO_SERVER); - final byte[] buf = new byte[PAYLOAD_TO_CLIENT.length]; - final long r = s.getInputStream().read(buf); - LOG.debug("Read {} payload from server", r); + final byte[] buf = new byte[PAYLOAD_TO_CLIENT.length]; + final long r = s.getInputStream().read(buf); + LOG.debug("Read {} payload from server", r); - assertEquals("Mismatched data length", PAYLOAD_TO_CLIENT.length, r); - s.close(); + assertEquals("Mismatched data length", PAYLOAD_TO_CLIENT.length, r); + return r; + } - return r; } }