test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java
changeset 59205 afcc8af048e6
parent 47216 71c04702a3d5
equal deleted inserted replaced
59204:7b10581e9632 59205:afcc8af048e6
     1 /*
     1 /*
     2  * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   108 
   108 
   109             /* TEST 6: AlreadyConnectedException */
   109             /* TEST 6: AlreadyConnectedException */
   110             try {
   110             try {
   111                 channel.close();  /* open a new unbound channel for test */
   111                 channel.close();  /* open a new unbound channel for test */
   112                 channel = SctpChannel.open();
   112                 channel = SctpChannel.open();
   113                 connectChannel(channel);
   113                 try (var peer = connectChannel(channel)) {
   114                 channel.bind(null);
   114                     channel.bind(null);
   115                 fail("AlreadyConnectedException expected");
   115                     fail("AlreadyConnectedException expected");
       
   116                 }
   116             } catch (AlreadyConnectedException unused) { pass();
   117             } catch (AlreadyConnectedException unused) { pass();
   117             } catch (IOException ioe) { unexpected(ioe); }
   118             } catch (IOException ioe) { unexpected(ioe); }
   118 
   119 
   119             /* TEST 7: ClosedChannelException - If this channel is closed */
   120             /* TEST 7: ClosedChannelException - If this channel is closed */
   120             try {
   121             try {
   262         } catch (IOException ioe) {
   263         } catch (IOException ioe) {
   263             ioe.printStackTrace();
   264             ioe.printStackTrace();
   264         } finally {
   265         } finally {
   265             try { if (channel != null) channel.close(); }
   266             try { if (channel != null) channel.close(); }
   266             catch (IOException ioe) { unexpected(ioe); }
   267             catch (IOException ioe) { unexpected(ioe); }
   267         }
   268             try { if (peerChannel != null) peerChannel.close(); }
       
   269             catch (IOException ioe) { unexpected(ioe); }
       
   270          }
   268     }
   271     }
   269 
   272 
   270     boolean boundAddress(SctpChannel channel, InetAddress addr)
   273     boolean boundAddress(SctpChannel channel, InetAddress addr)
   271         throws IOException {
   274         throws IOException {
   272         for (SocketAddress boundAddr : channel.getAllLocalAddresses()) {
   275         for (SocketAddress boundAddr : channel.getAllLocalAddresses()) {