--- a/test/jdk/java/net/httpclient/websocket/Support.java Mon Mar 19 21:04:01 2018 +0000
+++ b/test/jdk/java/net/httpclient/websocket/Support.java Tue Mar 20 00:30:20 2018 +0000
@@ -90,10 +90,20 @@
byte[] copy = Arrays.copyOf(data, data.length);
return new DummyWebSocketServer() {
@Override
- protected void serve(SocketChannel channel) throws IOException {
- ByteBuffer closeMessage = ByteBuffer.wrap(copy);
- channel.write(closeMessage);
- super.serve(channel);
+ protected void write(SocketChannel ch) throws IOException {
+ int off = 0; int n = 1; // 1 byte at a time
+ while (off + n < copy.length + n) {
+// try {
+// TimeUnit.MICROSECONDS.sleep(500);
+// } catch (InterruptedException e) {
+// return;
+// }
+ int len = Math.min(copy.length - off, n);
+ ByteBuffer bytes = ByteBuffer.wrap(copy, off, len);
+ off += len;
+ ch.write(bytes);
+ }
+ super.write(ch);
}
};
}
@@ -106,7 +116,7 @@
public static DummyWebSocketServer notReadingServer() {
return new DummyWebSocketServer() {
@Override
- protected void serve(SocketChannel channel) throws IOException {
+ protected void read(SocketChannel ch) throws IOException {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {