test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java
changeset 59205 afcc8af048e6
parent 47216 71c04702a3d5
--- a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java	Thu Nov 21 12:14:28 2019 +0000
+++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java	Thu Nov 21 12:14:29 2019 +0000
@@ -61,11 +61,10 @@
 
     void doTest() {
         SctpChannel channel = null;
-        SctpServerChannel ssc = null;
 
-        try {
+        try (SctpServerChannel ssc = SctpServerChannel.open()) {
             /* Create a server channel to connect to */
-            ssc = SctpServerChannel.open().bind(null);
+            ssc.bind(null);
             Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
             if (addrs.isEmpty())
                 debug("addrs should not be empty");
@@ -209,8 +208,6 @@
         } finally {
             try { if (channel != null) channel.close(); }
             catch (IOException unused) {}
-            try { if (ssc != null) ssc.close(); }
-            catch (IOException unused) {}
         }
     }