--- a/jdk/test/java/nio/channels/SocketChannel/UnboundSocketTests.java Tue Jun 22 19:18:06 2010 -0700
+++ b/jdk/test/java/nio/channels/SocketChannel/UnboundSocketTests.java Wed Jun 23 20:19:29 2010 +0100
@@ -57,39 +57,47 @@
System.out.println("\n-- SocketChannel --");
SocketChannel sc = SocketChannel.open();
+ try {
+ check("getLocalPort()", sc.socket().getLocalPort(), -1);
+ checkIsAnyLocalAddress("getLocalAddress()",
+ sc.socket().getLocalAddress());
+ check("getLocalSocketAddress()", sc.socket().getLocalSocketAddress(), null);
- check("getLocalPort()", sc.socket().getLocalPort(), -1);
- checkIsAnyLocalAddress("getLocalAddress()",
- sc.socket().getLocalAddress());
- check("getLocalSocketAddress()", sc.socket().getLocalSocketAddress(), null);
-
- check("getPort()", sc.socket().getPort(), 0);
- check("getInetAddress()", sc.socket().getInetAddress(), null);
- check("getRemoteSocketAddress()", sc.socket().getRemoteSocketAddress(), null);
-
+ check("getPort()", sc.socket().getPort(), 0);
+ check("getInetAddress()", sc.socket().getInetAddress(), null);
+ check("getRemoteSocketAddress()", sc.socket().getRemoteSocketAddress(), null);
+ } finally {
+ sc.close();
+ }
System.out.println("\n-- ServerSocketChannel --");
ServerSocketChannel ssc = ServerSocketChannel.open();
-
- check("getLocalPort()", ssc.socket().getLocalPort(), -1);
- check("getInetAddress()", ssc.socket().getInetAddress(), null);
- check("getLocalSocketAddress()", ssc.socket().getLocalSocketAddress(), null);
+ try {
+ check("getLocalPort()", ssc.socket().getLocalPort(), -1);
+ check("getInetAddress()", ssc.socket().getInetAddress(), null);
+ check("getLocalSocketAddress()", ssc.socket().getLocalSocketAddress(), null);
+ } finally {
+ ssc.close();
+ }
System.out.println("\n-- DatagramChannel --");
DatagramChannel dc = DatagramChannel.open();
-
- // not specified
- check("getLocalPort()", dc.socket().getLocalPort(), 0);
+ try {
+ // not specified
+ check("getLocalPort()", dc.socket().getLocalPort(), 0);
- checkIsAnyLocalAddress("getLocalAddress()",
- dc.socket().getLocalAddress());
- check("getLocalSocketAddress()", dc.socket().getLocalSocketAddress(), null);
+ checkIsAnyLocalAddress("getLocalAddress()",
+ dc.socket().getLocalAddress());
+ check("getLocalSocketAddress()", dc.socket().getLocalSocketAddress(), null);
- check("getPort()", dc.socket().getPort(), -1);
- check("getInetAddress()", dc.socket().getInetAddress(), null);
- check("getRemoteSocketAddress()", dc.socket().getRemoteSocketAddress(), null);
+ check("getPort()", dc.socket().getPort(), -1);
+ check("getInetAddress()", dc.socket().getInetAddress(), null);
+ check("getRemoteSocketAddress()", dc.socket().getRemoteSocketAddress(), null);
+ } finally {
+ dc.close();
+ }
if (failures > 0) {
throw new RuntimeException(failures + " sub-tests(s) failed.");