diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/HttpResponseHeaderParser.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/HttpResponseHeaderParser.java index 8b67dfdef44..48e302a0843 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/HttpResponseHeaderParser.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/HttpResponseHeaderParser.java @@ -81,7 +81,7 @@ public class HttpResponseHeaderParser if (parseHeader(line)) { // Finished parsing entire header - ByteBuffer copy = ByteBuffer.allocate(buf.remaining()); + ByteBuffer copy = ByteBuffer.allocateDirect(buf.remaining()); BufferUtil.put(buf,copy); BufferUtil.flipToFlush(copy,0); this.response.setRemainingBuffer(copy); diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java index a97c255572c..12349e7b468 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer; @@ -103,7 +104,7 @@ public class TomcatServerQuirksTest // Have server write frame. int length = bufferSize / 2; - ByteBuffer serverFrame = ByteBuffer.allocate(bufferSize); + ByteBuffer serverFrame = ByteBuffer.allocateDirect(bufferSize); serverFrame.put((byte)(0x80 | 0x01)); // FIN + TEXT serverFrame.put((byte)0x7E); // No MASK and 2 bytes length serverFrame.put((byte)(length >> 8)); // first length byte @@ -113,7 +114,7 @@ public class TomcatServerQuirksTest serverFrame.put((byte)'x'); } serverFrame.flip(); - byte buf[] = serverFrame.array(); + byte buf[] = BufferUtil.toArray(serverFrame); socket.write(buf,0,buf.length); socket.flush(); diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/internal/io/HttpResponseHeaderParserTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/internal/io/HttpResponseHeaderParserTest.java index d2f882216f3..f9ec77efbac 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/internal/io/HttpResponseHeaderParserTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/internal/io/HttpResponseHeaderParserTest.java @@ -64,7 +64,7 @@ public class HttpResponseHeaderParserTest expected.add(""); // Prepare Buffer - ByteBuffer buf = ByteBuffer.allocate(512); + ByteBuffer buf = ByteBuffer.allocateDirect(512); for (String line : expected) { appendUtf8(buf,line + "\r\n"); @@ -104,7 +104,7 @@ public class HttpResponseHeaderParserTest expected.add(""); // Prepare Buffer - ByteBuffer buf = ByteBuffer.allocate(512); + ByteBuffer buf = ByteBuffer.allocateDirect(512); for (String line : expected) { appendUtf8(buf,line + "\r\n"); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethod.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethod.java index a989254fb86..d55b8aa5d14 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethod.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethod.java @@ -83,7 +83,7 @@ public class DeflateCompressionMethod implements CompressionMethod public ByteBuffer process() { // prepare the output buffer - ByteBuffer buf = ByteBuffer.allocate(bufferSize); + ByteBuffer buf = ByteBuffer.allocateDirect(bufferSize); BufferUtil.clearToFill(buf); while (!deflater.finished()) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxParser.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxParser.java index 0fb2a498846..c39e7b953d1 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxParser.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxParser.java @@ -243,7 +243,7 @@ public class MuxParser private void parseDataFramePayload(ByteBuffer buffer) { int capacity = buffer.remaining(); - ByteBuffer payload = ByteBuffer.allocate(capacity); + ByteBuffer payload = ByteBuffer.allocateDirect(capacity); payload.put(buffer); BufferUtil.flipToFlush(payload,0); muxframe.setPayload(payload); @@ -336,7 +336,7 @@ public class MuxParser throw new MuxException(err); } - ByteBuffer ret = ByteBuffer.allocate((int)size); + ByteBuffer ret = ByteBuffer.allocateDirect((int)size); BufferUtil.put(buffer,ret); BufferUtil.flipToFlush(ret,0); return ret; diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java index 21f4ce18869..8ebb4f324f5 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java @@ -45,7 +45,7 @@ public class MessageInputStream extends InputStream implements MessageAppender public MessageInputStream(AnnotatedEventDriver driver) { this.driver = driver; - this.buf = ByteBuffer.allocate(BUFFER_SIZE); + this.buf = ByteBuffer.allocateDirect(BUFFER_SIZE); BufferUtil.clearToFill(this.buf); size = 0; readPosition = this.buf.position(); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java index 4fe7cf28fe1..b81c391d099 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java @@ -37,12 +37,12 @@ public class ClosePayloadParserTest String expectedReason = "Game Over"; byte utf[] = expectedReason.getBytes(StringUtil.__UTF8_CHARSET); - ByteBuffer payload = ByteBuffer.allocate(utf.length + 2); + ByteBuffer payload = ByteBuffer.allocateDirect(utf.length + 2); payload.putChar((char)StatusCode.NORMAL); payload.put(utf,0,utf.length); payload.flip(); - ByteBuffer buf = ByteBuffer.allocate(24); + ByteBuffer buf = ByteBuffer.allocateDirect(24); buf.put((byte)(0x80 | OpCode.CLOSE)); // fin + close buf.put((byte)(0x80 | payload.remaining())); MaskedByteBuffer.putMask(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java index d14e1b99563..0baf74204e2 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java @@ -139,7 +139,7 @@ public class GeneratorTest // Buffer to capture generated bytes (we do this to validate that the masking // is working correctly - ByteBuffer completeBuf = ByteBuffer.allocate(payload.length + expectedHeaderSize); + ByteBuffer completeBuf = ByteBuffer.allocateDirect(payload.length + expectedHeaderSize); BufferUtil.clearToFill(completeBuf); // Generate and capture generator output diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java index abc5205d0ad..cd266744800 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java @@ -191,7 +191,7 @@ public class ParserTest @Test public void testParseCase6_4_3() { - ByteBuffer payload = ByteBuffer.allocate(64); + ByteBuffer payload = ByteBuffer.allocateDirect(64); BufferUtil.clearToFill(payload); payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good payload.put(TypeUtil.fromHexString("f4908080")); // INVALID @@ -205,9 +205,9 @@ public class ParserTest ByteBuffer buf = new UnitGenerator().generate(text); - ByteBuffer part1 = ByteBuffer.allocate(17); // header + good - ByteBuffer part2 = ByteBuffer.allocate(4); // invalid - ByteBuffer part3 = ByteBuffer.allocate(10); // the rest (all good utf) + ByteBuffer part1 = ByteBuffer.allocateDirect(17); // header + good + ByteBuffer part2 = ByteBuffer.allocateDirect(4); // invalid + ByteBuffer part3 = ByteBuffer.allocateDirect(10); // the rest (all good utf) BufferUtil.put(buf,part1); BufferUtil.put(buf,part2); @@ -235,7 +235,7 @@ public class ParserTest @Test public void testParseNothing() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); // Put nothing in the buffer. buf.flip(); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java index ed212dba673..c627e617084 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java @@ -33,7 +33,7 @@ public class PingPayloadParserTest @Test public void testBasicPingParsing() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); BufferUtil.clearToFill(buf); buf.put(new byte[] { (byte)0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f }); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java index 81ec460403a..cfcdbd27286 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java @@ -21,9 +21,6 @@ package org.eclipse.jetty.websocket.common; import java.nio.ByteBuffer; import java.util.Arrays; -import org.eclipse.jetty.websocket.common.Generator; -import org.eclipse.jetty.websocket.common.OpCode; -import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.junit.Test; public class RFC6455ExamplesGeneratorTest @@ -41,12 +38,12 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer actual1 = generator.generate(text1); ByteBuffer actual2 = generator.generate(text2); - ByteBuffer expected1 = ByteBuffer.allocate(5); + ByteBuffer expected1 = ByteBuffer.allocateDirect(5); expected1.put(new byte[] { (byte)0x01, (byte)0x03, (byte)0x48, (byte)0x65, (byte)0x6c }); - ByteBuffer expected2 = ByteBuffer.allocate(4); + ByteBuffer expected2 = ByteBuffer.allocateDirect(4); expected2.put(new byte[] { (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f }); @@ -70,7 +67,7 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer actual = gen.generate(pong); - ByteBuffer expected = ByteBuffer.allocate(11); + ByteBuffer expected = ByteBuffer.allocateDirect(11); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // Unmasked Pong request expected.put(new byte[] @@ -90,7 +87,7 @@ public class RFC6455ExamplesGeneratorTest Generator gen = new UnitGenerator(); ByteBuffer actual = gen.generate(text); - ByteBuffer expected = ByteBuffer.allocate(11); + ByteBuffer expected = ByteBuffer.allocateDirect(11); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // A single-frame masked text message expected.put(new byte[] @@ -114,7 +111,7 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer actual = gen.generate(binary); - ByteBuffer expected = ByteBuffer.allocate(dataSize + FUDGE); + ByteBuffer expected = ByteBuffer.allocateDirect(dataSize + FUDGE); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // 256 bytes binary message in a single unmasked frame expected.put(new byte[] @@ -145,7 +142,7 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer actual = gen.generate(binary); - ByteBuffer expected = ByteBuffer.allocate(dataSize + 10); + ByteBuffer expected = ByteBuffer.allocateDirect(dataSize + 10); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // 64k bytes binary message in a single unmasked frame expected.put(new byte[] @@ -171,7 +168,7 @@ public class RFC6455ExamplesGeneratorTest Generator gen = new UnitGenerator(); ByteBuffer actual = gen.generate(ping); - ByteBuffer expected = ByteBuffer.allocate(10); + ByteBuffer expected = ByteBuffer.allocateDirect(10); expected.put(new byte[] { (byte)0x89, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f }); expected.flip(); // make readable @@ -188,7 +185,7 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer actual = generator.generate(text); - ByteBuffer expected = ByteBuffer.allocate(10); + ByteBuffer expected = ByteBuffer.allocateDirect(10); expected.put(new byte[] { (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f }); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java index fb36b4bb5fe..f326d08e735 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java @@ -42,7 +42,7 @@ public class RFC6455ExamplesParserTest IncomingFramesCapture capture = new IncomingFramesCapture(); parser.setIncomingFramesHandler(capture); - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); BufferUtil.clearToFill(buf); // Raw bytes as found in RFC 6455, Section 5.7 - Examples @@ -75,7 +75,7 @@ public class RFC6455ExamplesParserTest @Test public void testSingleMaskedPongRequest() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // Unmasked Pong request buf.put(new byte[] @@ -98,7 +98,7 @@ public class RFC6455ExamplesParserTest @Test public void testSingleMaskedTextMessage() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // A single-frame masked text message buf.put(new byte[] @@ -123,7 +123,7 @@ public class RFC6455ExamplesParserTest { int dataSize = 256; - ByteBuffer buf = ByteBuffer.allocate(dataSize + 10); + ByteBuffer buf = ByteBuffer.allocateDirect(dataSize + 10); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // 256 bytes binary message in a single unmasked frame buf.put(new byte[] @@ -162,7 +162,7 @@ public class RFC6455ExamplesParserTest { int dataSize = 1024 * 64; - ByteBuffer buf = ByteBuffer.allocate((dataSize + 10)); + ByteBuffer buf = ByteBuffer.allocateDirect((dataSize + 10)); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // 64 Kbytes binary message in a single unmasked frame buf.put(new byte[] @@ -198,7 +198,7 @@ public class RFC6455ExamplesParserTest @Test public void testSingleUnmaskedPingRequest() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // Unmasked Ping request buf.put(new byte[] @@ -221,7 +221,7 @@ public class RFC6455ExamplesParserTest @Test public void testSingleUnmaskedTextMessage() { - ByteBuffer buf = ByteBuffer.allocate(16); + ByteBuffer buf = ByteBuffer.allocateDirect(16); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // A single-frame unmasked text message buf.put(new byte[] diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java index ccfb53f0682..c5a04a0ab29 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java @@ -44,7 +44,7 @@ public class TextPayloadParserTest Assert.assertThat("Must be a medium length payload",utf.length,allOf(greaterThan(0x7E),lessThan(0xFFFF))); - ByteBuffer buf = ByteBuffer.allocate(utf.length + 8); + ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 8); buf.put((byte)0x81); buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length) buf.putShort((short)utf.length); @@ -79,7 +79,7 @@ public class TextPayloadParserTest Assert.assertThat("Must be a long length payload",utf.length,greaterThan(0xFFFF)); - ByteBuffer buf = ByteBuffer.allocate(utf.length + 32); + ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 32); buf.put((byte)0x81); buf.put((byte)(0x80 | 0x7F)); // 0x7F == 127 (a 8 byte payload length) buf.putLong(utf.length); @@ -115,7 +115,7 @@ public class TextPayloadParserTest Assert.assertThat("Must be a medium length payload",utf.length,allOf(greaterThan(0x7E),lessThan(0xFFFF))); - ByteBuffer buf = ByteBuffer.allocate(utf.length + 10); + ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 10); buf.put((byte)0x81); buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length) buf.putShort((short)utf.length); @@ -144,7 +144,7 @@ public class TextPayloadParserTest byte b1[] = part1.getBytes(StringUtil.__UTF8_CHARSET); byte b2[] = part2.getBytes(StringUtil.__UTF8_CHARSET); - ByteBuffer buf = ByteBuffer.allocate(32); + ByteBuffer buf = ByteBuffer.allocateDirect(32); // part 1 buf.put((byte)0x01); // no fin + text @@ -180,7 +180,7 @@ public class TextPayloadParserTest String expectedText = "Hello World"; byte utf[] = expectedText.getBytes(StringUtil.__UTF8_CHARSET); - ByteBuffer buf = ByteBuffer.allocate(24); + ByteBuffer buf = ByteBuffer.allocateDirect(24); buf.put((byte)0x81); buf.put((byte)(0x80 | utf.length)); MaskedByteBuffer.putMask(buf); @@ -206,7 +206,7 @@ public class TextPayloadParserTest byte utf[] = expectedText.getBytes(StringUtil.__UTF8); - ByteBuffer buf = ByteBuffer.allocate(24); + ByteBuffer buf = ByteBuffer.allocateDirect(24); buf.put((byte)0x81); buf.put((byte)(0x80 | utf.length)); MaskedByteBuffer.putMask(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/UnitGenerator.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/UnitGenerator.java index 0fbef69156f..4c5e0a11e0c 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/UnitGenerator.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/UnitGenerator.java @@ -46,7 +46,7 @@ public class UnitGenerator extends Generator { buflen += f.getPayloadLength() + Generator.OVERHEAD; } - ByteBuffer completeBuf = ByteBuffer.allocate(buflen); + ByteBuffer completeBuf = ByteBuffer.allocateDirect(buflen); BufferUtil.clearToFill(completeBuf); // Generate frames diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java index bd12408a95b..6c7f504c1b3 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java @@ -58,7 +58,7 @@ public class WebSocketFrameTest { WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE).setFin(false); ByteBuffer actual = laxGenerator.generate(frame); - ByteBuffer expected = ByteBuffer.allocate(2); + ByteBuffer expected = ByteBuffer.allocateDirect(2); expected.put((byte)0x08); expected.put((byte)0x00); @@ -70,7 +70,7 @@ public class WebSocketFrameTest { WebSocketFrame frame = new WebSocketFrame(OpCode.PING).setFin(false); ByteBuffer actual = laxGenerator.generate(frame); - ByteBuffer expected = ByteBuffer.allocate(2); + ByteBuffer expected = ByteBuffer.allocateDirect(2); expected.put((byte)0x09); expected.put((byte)0x00); @@ -82,7 +82,7 @@ public class WebSocketFrameTest { CloseInfo close = new CloseInfo(StatusCode.NORMAL); ByteBuffer actual = strictGenerator.generate(close.asFrame()); - ByteBuffer expected = ByteBuffer.allocate(4); + ByteBuffer expected = ByteBuffer.allocateDirect(4); expected.put((byte)0x88); expected.put((byte)0x02); expected.put((byte)0x03); @@ -96,7 +96,7 @@ public class WebSocketFrameTest { WebSocketFrame frame = new WebSocketFrame(OpCode.PING); ByteBuffer actual = strictGenerator.generate(frame); - ByteBuffer expected = ByteBuffer.allocate(2); + ByteBuffer expected = ByteBuffer.allocateDirect(2); expected.put((byte)0x89); expected.put((byte)0x00); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java index 755c5012e32..a8e12a2f9e4 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java @@ -60,7 +60,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -96,7 +96,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -136,7 +136,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -176,7 +176,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -217,7 +217,7 @@ public class TestABCase1_1 ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -255,7 +255,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 11); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 11); expected.put(new byte[] { (byte)0x81 }); @@ -284,7 +284,7 @@ public class TestABCase1_1 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(textFrame); - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x81, (byte)0x00 }); @@ -299,7 +299,7 @@ public class TestABCase1_1 { int length = 125; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -332,7 +332,7 @@ public class TestABCase1_1 { int length = 126; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -366,7 +366,7 @@ public class TestABCase1_1 { int length = 127; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -400,7 +400,7 @@ public class TestABCase1_1 { int length = 128; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -434,7 +434,7 @@ public class TestABCase1_1 { int length = 65535; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x81 }); @@ -470,7 +470,7 @@ public class TestABCase1_1 { int length = 65536; - ByteBuffer expected = ByteBuffer.allocate(length + 11); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 11); expected.put(new byte[] { (byte)0x81 }); @@ -506,7 +506,7 @@ public class TestABCase1_1 public void testParseEmptyTextCase1_1_1() { - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x81, (byte)0x00 }); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java index dd6d6eab621..a62f998202e 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java @@ -49,7 +49,7 @@ public class TestABCase1_2 { int length = 125; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -64,7 +64,7 @@ public class TestABCase1_2 ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -88,7 +88,7 @@ public class TestABCase1_2 { int length = 126; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -102,7 +102,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -130,7 +130,7 @@ public class TestABCase1_2 { int length = 127; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -145,7 +145,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -173,7 +173,7 @@ public class TestABCase1_2 { int length = 128; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -187,7 +187,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -216,7 +216,7 @@ public class TestABCase1_2 { int length = 65535; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -231,7 +231,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -256,7 +256,7 @@ public class TestABCase1_2 { int length = 65536; - ByteBuffer bb = ByteBuffer.allocate(length); + ByteBuffer bb = ByteBuffer.allocateDirect(length); for ( int i = 0 ; i < length ; ++i) { @@ -271,7 +271,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(length + 11); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 11); expected.put(new byte[] { (byte)0x82 }); @@ -300,7 +300,7 @@ public class TestABCase1_2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(binaryFrame); - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x82, (byte)0x00 }); @@ -315,7 +315,7 @@ public class TestABCase1_2 { int length = 125; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -348,7 +348,7 @@ public class TestABCase1_2 { int length = 126; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -382,7 +382,7 @@ public class TestABCase1_2 { int length = 127; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -416,7 +416,7 @@ public class TestABCase1_2 { int length = 128; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -450,7 +450,7 @@ public class TestABCase1_2 { int length = 65535; - ByteBuffer expected = ByteBuffer.allocate(length + 5); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 5); expected.put(new byte[] { (byte)0x82 }); @@ -486,7 +486,7 @@ public class TestABCase1_2 { int length = 65536; - ByteBuffer expected = ByteBuffer.allocate(length + 11); + ByteBuffer expected = ByteBuffer.allocateDirect(length + 11); expected.put(new byte[] { (byte)0x82 }); @@ -521,7 +521,7 @@ public class TestABCase1_2 public void testParseEmptyBinaryCase1_2_1() { - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x82, (byte)0x00 }); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java index 13843bb7d77..2bd1ebe3575 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java @@ -58,7 +58,7 @@ public class TestABCase2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(pingFrame); - ByteBuffer expected = ByteBuffer.allocate(bytes.length + 32); + ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + 32); expected.put(new byte[] { (byte)0x89 }); @@ -83,7 +83,7 @@ public class TestABCase2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(pingFrame); - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x89 }); @@ -108,7 +108,7 @@ public class TestABCase2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(pingFrame); - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x89, (byte)0x00 }); @@ -129,7 +129,7 @@ public class TestABCase2 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(pingFrame); - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x89 }); @@ -183,7 +183,7 @@ public class TestABCase2 bytes[i] = Integer.valueOf(Integer.toOctalString(i)).byteValue(); } - ByteBuffer expected = ByteBuffer.allocate(bytes.length + 32); + ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + 32); expected.put(new byte[] { (byte)0x89 }); @@ -213,7 +213,7 @@ public class TestABCase2 { byte[] bytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x89 }); @@ -241,7 +241,7 @@ public class TestABCase2 @Test public void testParseEmptyPingCase2_1() { - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x89, (byte)0x00 }); @@ -267,7 +267,7 @@ public class TestABCase2 String message = "Hello, world!"; byte[] messageBytes = message.getBytes(); - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x89 }); @@ -298,7 +298,7 @@ public class TestABCase2 byte[] bytes = new byte[126]; Arrays.fill(bytes,(byte)0x00); - ByteBuffer expected = ByteBuffer.allocate(bytes.length + Generator.OVERHEAD); + ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + Generator.OVERHEAD); byte b; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java index 562c0b2941b..c77f67e8fe5 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java @@ -51,7 +51,7 @@ public class TestABCase4 @Test public void testParserControlOpCode11Case4_2_1() { - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x8b, 0x00 }); @@ -73,7 +73,7 @@ public class TestABCase4 @Test public void testParserControlOpCode12WithPayloadCase4_2_2() { - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x8c, 0x01, 0x00 }); @@ -96,7 +96,7 @@ public class TestABCase4 @Test public void testParserNonControlOpCode3Case4_1_1() { - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x83, 0x00 }); @@ -118,7 +118,7 @@ public class TestABCase4 @Test public void testParserNonControlOpCode4WithPayloadCase4_1_2() { - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x84, 0x01, 0x00 }); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java index 4a3bd826ed1..8a89d803883 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java @@ -53,7 +53,7 @@ public class TestABCase7_3 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(close.asFrame()); - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x88, (byte)0x00 }); @@ -66,7 +66,7 @@ public class TestABCase7_3 @Test public void testCase7_3_1ParseEmptyClose() { - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x88, (byte)0x00 }); @@ -100,7 +100,7 @@ public class TestABCase7_3 @Test public void testCase7_3_2Parse1BytePayloadClose() { - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x88, 0x01, 0x00 }); @@ -127,7 +127,7 @@ public class TestABCase7_3 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(close.asFrame()); - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 }); @@ -140,7 +140,7 @@ public class TestABCase7_3 @Test public void testCase7_3_3ParseCloseWithStatus() { - ByteBuffer expected = ByteBuffer.allocate(5); + ByteBuffer expected = ByteBuffer.allocateDirect(5); expected.put(new byte[] { (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 }); @@ -172,7 +172,7 @@ public class TestABCase7_3 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(close.asFrame()); - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x88 }); @@ -194,7 +194,7 @@ public class TestABCase7_3 String message = "bad cough"; byte[] messageBytes = message.getBytes(); - ByteBuffer expected = ByteBuffer.allocate(32); + ByteBuffer expected = ByteBuffer.allocateDirect(32); expected.put(new byte[] { (byte)0x88 }); @@ -232,7 +232,7 @@ public class TestABCase7_3 Generator generator = new UnitGenerator(); ByteBuffer actual = generator.generate(close.asFrame()); - ByteBuffer expected = ByteBuffer.allocate(132); + ByteBuffer expected = ByteBuffer.allocateDirect(132); byte messageBytes[] = message.toString().getBytes(StringUtil.__UTF8_CHARSET); @@ -262,7 +262,7 @@ public class TestABCase7_3 byte[] messageBytes = message.toString().getBytes(StringUtil.__UTF8_CHARSET); - ByteBuffer expected = ByteBuffer.allocate(132); + ByteBuffer expected = ByteBuffer.allocateDirect(132); expected.put(new byte[] { (byte)0x88 }); @@ -301,7 +301,7 @@ public class TestABCase7_3 WebSocketFrame closeFrame = new WebSocketFrame(OpCode.CLOSE); - ByteBuffer bb = ByteBuffer.allocate(WebSocketFrame.MAX_CONTROL_PAYLOAD + 1); // 126 which is too big for control + ByteBuffer bb = ByteBuffer.allocateDirect(WebSocketFrame.MAX_CONTROL_PAYLOAD + 1); // 126 which is too big for control bb.putChar((char)1000); bb.put(messageBytes); @@ -320,7 +320,7 @@ public class TestABCase7_3 byte[] messageBytes = new byte[124]; Arrays.fill(messageBytes,(byte)'*'); - ByteBuffer expected = ByteBuffer.allocate(256); + ByteBuffer expected = ByteBuffer.allocateDirect(256); byte b; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethodTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethodTest.java index 32f741ee2c4..0f0b30ae9c0 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethodTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/DeflateCompressionMethodTest.java @@ -56,7 +56,7 @@ public class DeflateCompressionMethodTest method.compress().end(); // decompress - ByteBuffer decompressed = ByteBuffer.allocate(msg.length()); + ByteBuffer decompressed = ByteBuffer.allocateDirect(msg.length()); LOG.debug("decompressed(a): {}",BufferUtil.toDetailString(decompressed)); method.decompress().begin(); method.decompress().input(compressed); @@ -89,7 +89,7 @@ public class DeflateCompressionMethodTest CompressionMethod method = new DeflateCompressionMethod(); // Decompressed Data Holder - ByteBuffer decompressed = ByteBuffer.allocate(32); + ByteBuffer decompressed = ByteBuffer.allocateDirect(32); BufferUtil.flipToFill(decompressed); // Perform Decompress on Buf 1 diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java index 68f47308ebc..ba781cd20c4 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java @@ -179,7 +179,7 @@ public class FrameCompressionExtensionTest compressor.finish(); // Perform compression - ByteBuffer outbuf = ByteBuffer.allocate(64); + ByteBuffer outbuf = ByteBuffer.allocateDirect(64); BufferUtil.clearToFill(outbuf); while (!compressor.finished()) diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWrite139SizeTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWrite139SizeTest.java index acdc204e653..380a5a28dfe 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWrite139SizeTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWrite139SizeTest.java @@ -88,7 +88,7 @@ public class MuxGeneratorWrite139SizeTest public void testWrite139Size() { System.err.printf("Running %s.%s - value: %,d%n",this.getClass().getName(),testname.getMethodName(),value); - ByteBuffer bbuf = ByteBuffer.allocate(10); + ByteBuffer bbuf = ByteBuffer.allocateDirect(10); generator.write139Size(bbuf,value); BufferUtil.flipToFlush(bbuf,0); byte actual[] = BufferUtil.toArray(bbuf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWriteChannelIdTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWriteChannelIdTest.java index 4fe5fdbe8a2..daf33e5e2db 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWriteChannelIdTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGeneratorWriteChannelIdTest.java @@ -92,7 +92,7 @@ public class MuxGeneratorWriteChannelIdTest public void testReadChannelId() { System.err.printf("Running %s.%s - channelId: %,d%n",this.getClass().getName(),testname.getMethodName(),channelId); - ByteBuffer bbuf = ByteBuffer.allocate(10); + ByteBuffer bbuf = ByteBuffer.allocateDirect(10); generator.writeChannelId(bbuf,channelId); BufferUtil.flipToFlush(bbuf,0); byte actual[] = BufferUtil.toArray(bbuf); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java index 09e9f3ec173..13f99ad3194 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java @@ -101,7 +101,7 @@ public class Fuzzer { buflen += f.getPayloadLength() + Generator.OVERHEAD; } - ByteBuffer buf = ByteBuffer.allocate(buflen); + ByteBuffer buf = ByteBuffer.allocateDirect(buflen); BufferUtil.clearToFill(buf); // Generate frames @@ -271,7 +271,7 @@ public class Fuzzer { buflen += f.getPayloadLength() + Generator.OVERHEAD; } - ByteBuffer buf = ByteBuffer.allocate(buflen); + ByteBuffer buf = ByteBuffer.allocateDirect(buflen); BufferUtil.clearToFill(buf); // Generate frames diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java index fbf87f84818..3435a3fa0a8 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java @@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.server.ab; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; import org.eclipse.jetty.toolchain.test.AdvancedRunner; import org.eclipse.jetty.toolchain.test.annotation.Slow; @@ -299,9 +298,7 @@ public class TestABCase6 extends AbstractABCase fuzzer.setSendMode(Fuzzer.SendMode.BULK); fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false)); - TimeUnit.SECONDS.sleep(1); fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false)); - TimeUnit.SECONDS.sleep(1); fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true)); fuzzer.expect(expect); @@ -338,9 +335,7 @@ public class TestABCase6 extends AbstractABCase fuzzer.connect(); fuzzer.setSendMode(Fuzzer.SendMode.BULK); fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false)); - TimeUnit.SECONDS.sleep(1); fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false)); - TimeUnit.SECONDS.sleep(1); fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true)); fuzzer.expect(expect); } @@ -360,7 +355,7 @@ public class TestABCase6 extends AbstractABCase // Disable Long Stacks from Parser (we know this test will throw an exception) enableStacks(Parser.class,false); - ByteBuffer payload = ByteBuffer.allocate(64); + ByteBuffer payload = ByteBuffer.allocateDirect(64); BufferUtil.clearToFill(payload); payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good payload.put(TypeUtil.fromHexString("f4908080")); // INVALID @@ -394,12 +389,10 @@ public class TestABCase6 extends AbstractABCase part3.limit(splits[2]); fuzzer.send(part1); // the header + good utf - TimeUnit.SECONDS.sleep(1); fuzzer.send(part2); // the bad UTF fuzzer.expect(expect); - TimeUnit.SECONDS.sleep(1); fuzzer.sendExpectingIOException(part3); // the rest (shouldn't work) } finally @@ -436,9 +429,7 @@ public class TestABCase6 extends AbstractABCase ByteBuffer net = fuzzer.asNetworkBuffer(send); fuzzer.send(net,6); fuzzer.send(net,11); - TimeUnit.SECONDS.sleep(1); fuzzer.send(net,1); - TimeUnit.SECONDS.sleep(1); fuzzer.send(net,100); // the rest fuzzer.expect(expect); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java index d6e71a96588..249dd9fca6d 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java @@ -367,7 +367,7 @@ public class TestABCase7 extends AbstractABCase @Test public void testCase7_3_6() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.put((byte)0xE8); payload.put((byte)0x03); @@ -408,7 +408,7 @@ public class TestABCase7 extends AbstractABCase @Test public void testCase7_5_1() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.put((byte)0x03); // normal close payload.put((byte)0xE8); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_BadStatusCodes.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_BadStatusCodes.java index 727be4dd023..4254fa17bde 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_BadStatusCodes.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_BadStatusCodes.java @@ -86,7 +86,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase @Test public void testBadStatusCode() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.putChar((char)statusCode); BufferUtil.flipToFlush(payload,0); @@ -118,7 +118,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase @Test public void testBadStatusCodeWithReason() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.putChar((char)statusCode); payload.put(StringUtil.getBytes("Reason")); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_GoodStatusCodes.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_GoodStatusCodes.java index 7343c57d466..674c3ab3254 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_GoodStatusCodes.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_GoodStatusCodes.java @@ -81,7 +81,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase @Test public void testStatusCode() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.putChar((char)statusCode); BufferUtil.flipToFlush(payload,0); @@ -113,7 +113,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase @Test public void testStatusCodeWithReason() throws Exception { - ByteBuffer payload = ByteBuffer.allocate(256); + ByteBuffer payload = ByteBuffer.allocateDirect(256); BufferUtil.clearToFill(payload); payload.putChar((char)statusCode); payload.put(StringUtil.getBytes("Reason")); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoBroadcastPingSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoBroadcastPingSocket.java index 5205e0557e5..42cbff88d74 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoBroadcastPingSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoBroadcastPingSocket.java @@ -46,7 +46,7 @@ public class EchoBroadcastPingSocket extends EchoBroadcastSocket while (!latch.await(10,TimeUnit.SECONDS)) { System.err.println("Ping"); - ByteBuffer data = ByteBuffer.allocate(3); + ByteBuffer data = ByteBuffer.allocateDirect(3); data.put(new byte[] { (byte)1, (byte)2, (byte)3 }); data.flip(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/SafariD00.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/SafariD00.java index d7206349196..55a52535eea 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/SafariD00.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/SafariD00.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.websocket.server.helper; +import static org.hamcrest.Matchers.*; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -34,8 +36,6 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.TypeUtil; import org.junit.Assert; -import static org.hamcrest.Matchers.is; - public class SafariD00 { private URI uri; @@ -52,7 +52,7 @@ public class SafariD00 /** * Open the Socket to the destination endpoint and - * + * * @return the open java Socket. * @throws IOException */ @@ -74,7 +74,7 @@ public class SafariD00 /** * Issue an Http websocket (Draft-0) upgrade request using the Safari particulars. - * + * * @throws UnsupportedEncodingException */ public void issueHandshake() throws IOException @@ -135,7 +135,7 @@ public class SafariD00 len += (msg.length() + 2); } - ByteBuffer buf = ByteBuffer.allocate(len); + ByteBuffer buf = ByteBuffer.allocateDirect(len); for (String msg : msgs) {