From 246920e93022eb6e470e698456ce313e541bc350 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 5 Oct 2010 15:07:40 +0100 Subject: [PATCH] 6987116: (so) test/java/nio/channels/SocketChannel/VectorIO.java failed on Solaris 11 Reviewed-by: forax --- .../nio/channels/SocketChannel/VectorIO.java | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java index 0dfd2d66f8a..58215c024bb 100644 --- a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java +++ b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java @@ -60,6 +60,7 @@ public class VectorIO { static void bufferTest(int port) throws Exception { ByteBuffer[] bufs = new ByteBuffer[testSize]; + long total = 0L; for(int i=0; i 0); - - try { - Thread.currentThread().sleep(500); - } catch (InterruptedException ie) { } + long rem = total; + while (rem > 0L) { + long bytesWritten = sc.write(bufs); + if (bytesWritten == 0) { + if (sc.isBlocking()) + throw new RuntimeException("write did not block"); + Thread.sleep(50); + } else { + rem -= bytesWritten; + } + } // Clean up sc.close(); @@ -115,6 +120,7 @@ public class VectorIO { } void bufferTest() throws Exception { + long total = 0L; ByteBuffer[] bufs = new ByteBuffer[testSize]; for(int i=0; i 0); + long avail = total; + while (avail > 0) { + long bytesRead = sc.read(bufs); + if (bytesRead < 0) + break; + if (bytesRead == 0) { + if (sc.isBlocking()) + throw new RuntimeException("read did not block"); + Thread.sleep(50); + } + avail -= bytesRead; + } // Check results for(int i=0; i