From 86a40825c74ce77036bb6922add1a73809996775 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 27 Jul 2009 18:46:50 +0100 Subject: [PATCH] 6863667: (ch) Several tests in java/nio/channels/* need to be updated after 6638712 Reviewed-by: mcimadamore --- .../AsynchronousChannelGroup/GroupOfOne.java | 8 +++--- .../AsynchronousChannelGroup/Identity.java | 8 +++--- .../AsynchronousChannelGroup/Restart.java | 2 +- .../AsynchronousChannelGroup/Unbounded.java | 4 +-- .../AsynchronousDatagramChannel/Basic.java | 22 +++++++-------- .../AsynchronousFileChannel/Basic.java | 8 +++--- .../Basic.java | 2 +- .../AsynchronousSocketChannel/Basic.java | 28 +++++++++---------- .../StressLoopback.java | 8 +++--- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java index b116245ceaf..4478c9bd851 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java @@ -44,9 +44,9 @@ public class GroupOfOne { final AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open() .bind(new InetSocketAddress(0)); - listener.accept(null, new CompletionHandler() { + listener.accept((Void)null, new CompletionHandler() { public void completed(AsynchronousSocketChannel ch, Void att) { - listener.accept(null, this); + listener.accept((Void)null, this); } public void failed(Throwable exc, Void att) { } @@ -81,13 +81,13 @@ public class GroupOfOne { // 2. the close/shutdown completes final CountDownLatch latch = new CountDownLatch(2); - ch.connect(sa, null, new CompletionHandler() { + ch.connect(sa, (Void)null, new CompletionHandler() { public void completed(Void result, Void att) { System.out.println("Connected"); // initiate I/O operation that does not complete (successfully) ByteBuffer buf = ByteBuffer.allocate(100); - ch.read(buf, null, new CompletionHandler() { + ch.read(buf, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { throw new RuntimeException(); } diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java index f41c12c807f..6214df2e1f5 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java @@ -78,15 +78,15 @@ public class Identity { final AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open() .bind(new InetSocketAddress(0)); - listener.accept(null, new CompletionHandler() { + listener.accept((Void)null, new CompletionHandler() { public void completed(final AsynchronousSocketChannel ch, Void att) { - listener.accept(null, this); + listener.accept((Void)null, this); final ByteBuffer buf = ByteBuffer.allocate(100); - ch.read(buf, null, new CompletionHandler() { + ch.read(buf, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { buf.clear(); - ch.read(buf, null, this); + ch.read(buf, (Void)null, this); } public void failed(Throwable exc, Void att) { } diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java index 567321e3008..f2132270e50 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java @@ -94,7 +94,7 @@ public class Restart { for (int i=0; i() { + listener.accept((Void)null, new CompletionHandler() { public void completed(AsynchronousSocketChannel ch, Void att) { try { ch.close(); diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java index f615c3c5063..f77f2fc3c2d 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java @@ -45,10 +45,10 @@ public class Unbounded { final AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open() .bind(new InetSocketAddress(0)); - listener.accept(null, new CompletionHandler() { + listener.accept((Void)null, new CompletionHandler() { public void completed(AsynchronousSocketChannel ch, Void att) { queue.add(ch); - listener.accept(null, this); + listener.accept((Void)null, this); } public void failed(Throwable exc, Void att) { } diff --git a/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java index 5ed3d83a90d..f90800f392d 100644 --- a/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java @@ -66,7 +66,7 @@ public class Basic { // Test: datagram packet not received immediately dst.clear(); final CountDownLatch latch = new CountDownLatch(1); - ch.receive(dst, null, new CompletionHandler() { + ch.receive(dst, (Void)null, new CompletionHandler() { public void completed(SocketAddress source, Void att) { latch.countDown(); } @@ -82,7 +82,7 @@ public class Basic { // Test: timeout dst.clear(); final AtomicReference exception = new AtomicReference(); - ch.receive(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler() { + ch.receive(dst, 2, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(SocketAddress source, Void att) { } public void failed (Throwable exc, Void att) { @@ -101,7 +101,7 @@ public class Basic { // AsynchronousCloseException dst = ByteBuffer.allocateDirect(100); exception.set(null); - ch.receive(dst, null, new CompletionHandler() { + ch.receive(dst, (Void)null, new CompletionHandler() { public void completed(SocketAddress source, Void att) { } public void failed (Throwable exc, Void att) { @@ -156,7 +156,7 @@ public class Basic { // Test: datagram packet not received immediately dst.clear(); final CountDownLatch l1 = new CountDownLatch(1); - ch.read(dst, null, new CompletionHandler() { + ch.read(dst, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { l1.countDown(); } @@ -172,7 +172,7 @@ public class Basic { // Test: timeout dst.clear(); final AtomicReference exception = new AtomicReference(); - ch.read(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler() { + ch.read(dst, 2, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { } public void failed (Throwable exc, Void att) { @@ -191,7 +191,7 @@ public class Basic { // AsynchronousCloseException dst.clear(); exception.set(null); - ch.read(dst, null, new CompletionHandler() { + ch.read(dst, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { } public void failed (Throwable exc, Void att) { @@ -238,7 +238,7 @@ public class Basic { // Test: send datagram packet to reader and check completion handler // is invoked final CountDownLatch l2 = new CountDownLatch(1); - ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler() { + ch.send(ByteBuffer.wrap(msg), sa, (Void)null, new CompletionHandler() { public void completed(Integer bytesSent, Void att) { if (bytesSent != msg.length) throw new RuntimeException("Unexpected number of bytes received"); @@ -261,7 +261,7 @@ public class Basic { // Test: check that failed method is invoked ch.close(); final CountDownLatch l3 = new CountDownLatch(1); - ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler() { + ch.send(ByteBuffer.wrap(msg), sa, (Void)null, new CompletionHandler() { public void completed(Integer bytesSent, Void att) { throw new RuntimeException("completed method invoked"); } @@ -315,7 +315,7 @@ public class Basic { // Test: write datagram and check completion handler is invoked final CountDownLatch l2 = new CountDownLatch(1); - ch.write(ByteBuffer.wrap(msg), null, new CompletionHandler() { + ch.write(ByteBuffer.wrap(msg), (Void)null, new CompletionHandler() { public void completed(Integer bytesSent, Void att) { if (bytesSent != msg.length) throw new RuntimeException("Unexpected number of bytes received"); @@ -372,7 +372,7 @@ public class Basic { final CountDownLatch latch = new CountDownLatch(1); long timeout = (i == 0) ? 0L : 60L; Future remote = ch - .receive(ByteBuffer.allocate(100), timeout, TimeUnit.SECONDS, null, + .receive(ByteBuffer.allocate(100), timeout, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(SocketAddress source, Void att) { } @@ -395,7 +395,7 @@ public class Basic { final CountDownLatch latch = new CountDownLatch(1); long timeout = (i == 0) ? 0L : 60L; Future result = ch - .read(ByteBuffer.allocate(100), timeout, TimeUnit.SECONDS, null, + .read(ByteBuffer.allocate(100), timeout, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(Integer bytesRead, Void att) { } diff --git a/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java index 1f37d4be11c..92241536642 100644 --- a/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java @@ -190,7 +190,7 @@ public class Basic { if (fl == null) throw new RuntimeException("Unable to acquire lock"); try { - ch.lock(null, new CompletionHandler () { + ch.lock((Void)null, new CompletionHandler () { public void completed(FileLock result, Void att) { } public void failed(Throwable exc, Void att) { @@ -217,7 +217,7 @@ public class Basic { ByteBuffer buf = ByteBuffer.allocateDirect(100); final CountDownLatch latch = new CountDownLatch(1); - ch.read(buf, 0L, null, new CompletionHandler() { + ch.read(buf, 0L, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { try { Thread.currentThread().interrupt(); @@ -311,7 +311,7 @@ public class Basic { final AtomicReference invoker = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); - ch.write(genBuffer(), 0L, null, new CompletionHandler() { + ch.write(genBuffer(), 0L, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { invoker.set(Thread.currentThread()); latch.countDown(); @@ -410,7 +410,7 @@ public class Basic { // start write operation final CountDownLatch latch = new CountDownLatch(1); - Future res = ch.write(genBuffer(), 0L, null, + Future res = ch.write(genBuffer(), 0L, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { } diff --git a/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java index e0965fb6e74..e648b78a911 100644 --- a/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java @@ -95,7 +95,7 @@ public class Basic { final AtomicReference exception = new AtomicReference(); // start accepting - listener.accept(null, new CompletionHandler() { + listener.accept((Void)null, new CompletionHandler() { public void completed(AsynchronousSocketChannel ch, Void att) { try { ch.close(); diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java index 8b140f17bbf..3c04635312b 100644 --- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -181,7 +181,7 @@ public class Basic { } final AtomicReference connectException = new AtomicReference(); - ch.connect(server.address(), null, new CompletionHandler() { + ch.connect(server.address(), (Void)null, new CompletionHandler() { public void completed(Void result, Void att) { } public void failed(Throwable exc, Void att) { @@ -332,7 +332,7 @@ public class Basic { // start read operation final CountDownLatch latch = new CountDownLatch(1); ByteBuffer buf = ByteBuffer.allocate(1); - Future res = ch.read(buf, null, + Future res = ch.read(buf, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { } @@ -397,11 +397,11 @@ public class Basic { // reads should complete immediately final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity() + 100); final CountDownLatch latch = new CountDownLatch(1); - ch.read(dst, null, new CompletionHandler() { + ch.read(dst, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { int n = result; if (n > 0) { - ch.read(dst, null, this); + ch.read(dst, (Void)null, this); } else { latch.countDown(); } @@ -450,10 +450,10 @@ public class Basic { // read until the buffer is full final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity()); final CountDownLatch latch = new CountDownLatch(1); - ch.read(dst, null, new CompletionHandler() { + ch.read(dst, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { if (dst.hasRemaining()) { - ch.read(dst, null, this); + ch.read(dst, (Void)null, this); } else { latch.countDown(); } @@ -508,7 +508,7 @@ public class Basic { // scattering read that completes ascynhronously final CountDownLatch latch = new CountDownLatch(1); - ch.read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null, + ch.read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(Long result, Void att) { long n = result; @@ -536,7 +536,7 @@ public class Basic { dsts[i].rewind(); } long n = ch - .read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null, null).get(); + .read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, (Void)null, null).get(); if (n <= 0) throw new RuntimeException("No bytes read"); @@ -562,10 +562,10 @@ public class Basic { // write all bytes and close connection when done final ByteBuffer src = genBuffer(); - ch.write(src, null, new CompletionHandler() { + ch.write(src, (Void)null, new CompletionHandler() { public void completed(Integer result, Void att) { if (src.hasRemaining()) { - ch.write(src, null, this); + ch.write(src, (Void)null, this); } else { try { ch.close(); @@ -616,7 +616,7 @@ public class Basic { // write buffers (should complete immediately) ByteBuffer[] srcs = genBuffers(1); long n = ch - .write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null, null).get(); + .write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, (Void)null, null).get(); if (n <= 0) throw new RuntimeException("No bytes written"); @@ -629,7 +629,7 @@ public class Basic { // write until socket buffer is full so as to create the conditions // for when a write does not complete immediately srcs = genBuffers(1); - ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null, + ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, (Void)null, new CompletionHandler() { public void completed(Long result, Void att) { long n = result; @@ -639,7 +639,7 @@ public class Basic { if (continueWriting.get()) { ByteBuffer[] srcs = genBuffers(8); ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, - null, this); + (Void)null, this); } } public void failed(Throwable exc, Void att) { @@ -717,7 +717,7 @@ public class Basic { // this read should timeout ByteBuffer dst = ByteBuffer.allocate(512); try { - ch.read(dst, 3, TimeUnit.SECONDS, null, null).get(); + ch.read(dst, 3, TimeUnit.SECONDS, (Void)null, null).get(); throw new RuntimeException("Read did not timeout"); } catch (ExecutionException x) { if (!(x.getCause() instanceof InterruptedByTimeoutException)) diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java index d3426ba08c0..a3c0db687e6 100644 --- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java +++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java @@ -99,7 +99,7 @@ public class StressLoopback { void start() { sentBuffer.position(0); sentBuffer.limit(sentBuffer.capacity()); - channel.write(sentBuffer, null, new CompletionHandler () { + channel.write(sentBuffer, (Void)null, new CompletionHandler () { public void completed(Integer nwrote, Void att) { bytesSent += nwrote; if (finished) { @@ -107,7 +107,7 @@ public class StressLoopback { } else { sentBuffer.position(0); sentBuffer.limit(sentBuffer.capacity()); - channel.write(sentBuffer, null, this); + channel.write(sentBuffer, (Void)null, this); } } public void failed(Throwable exc, Void att) { @@ -142,14 +142,14 @@ public class StressLoopback { } void start() { - channel.read(readBuffer, null, new CompletionHandler () { + channel.read(readBuffer, (Void)null, new CompletionHandler () { public void completed(Integer nread, Void att) { if (nread < 0) { closeUnchecked(channel); } else { bytesRead += nread; readBuffer.clear(); - channel.read(readBuffer, null, this); + channel.read(readBuffer, (Void)null, this); } } public void failed(Throwable exc, Void att) {