From 5621f87c810cb8400c620e68d0ca5215d83f3d82 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 22 Feb 2013 12:57:36 -0700 Subject: [PATCH] Switching to direct ByteBuffers --- .../eclipse/jetty/websocket/client/io/UpgradeConnection.java | 2 +- .../org/eclipse/jetty/websocket/client/ServerReadThread.java | 2 +- .../jetty/websocket/client/blockhead/BlockheadServer.java | 4 ++-- .../java/org/eclipse/jetty/websocket/common/Generator.java | 2 +- .../main/java/org/eclipse/jetty/websocket/common/Parser.java | 2 +- .../jetty/websocket/common/extensions/mux/MuxGenerator.java | 4 ++-- .../websocket/common/io/AbstractWebSocketConnection.java | 2 +- .../jetty/websocket/common/GeneratorParserRoundtripTest.java | 4 ++-- .../jetty/websocket/server/blockhead/BlockheadClient.java | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java index b37a02a4a83..d2d35290e15 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java @@ -117,7 +117,7 @@ public class UpgradeConnection extends AbstractConnection @Override public void onFillable() { - ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); + ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true); BufferUtil.clear(buffer); boolean readMore = false; try diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java index 5d4e1731d0d..63356b4bf55 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java @@ -72,7 +72,7 @@ public class ServerReadThread extends Thread public void run() { ByteBufferPool bufferPool = conn.getBufferPool(); - ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); + ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true); BufferUtil.clearToFill(buf); int len = 0; diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java index b4d5ea4ba11..46ee708cb8c 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java @@ -310,7 +310,7 @@ public class BlockheadServer LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); int startCount = incomingFrames.size(); - ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); + ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true); BufferUtil.clearToFill(buf); try { @@ -403,7 +403,7 @@ public class BlockheadServer { LOG.debug("Entering echo thread"); - ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); + ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true); BufferUtil.clearToFill(buf); long readBytes = 0; try diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java index f16e7dec1ef..44c1bb34ae1 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java @@ -222,7 +222,7 @@ public class Generator /* * prepare the byte buffer to put frame into */ - ByteBuffer buffer = bufferPool.acquire(windowSize,false); + ByteBuffer buffer = bufferPool.acquire(windowSize,true); BufferUtil.clearToFill(buffer); if (LOG.isDebugEnabled()) { diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java index bca7e30eb60..eb1c1826dfa 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java @@ -553,7 +553,7 @@ public class Parser if (payload == null) { frame.assertValid(); - payload = bufferPool.acquire(payloadLength,false); + payload = bufferPool.acquire(payloadLength,true); BufferUtil.clearToFill(payload); } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGenerator.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGenerator.java index cf12f371833..652c724478b 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGenerator.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxGenerator.java @@ -57,7 +57,7 @@ public class MuxGenerator public void generate(long channelId, Frame frame, WriteCallback callback) { - ByteBuffer muxPayload = bufferPool.acquire(frame.getPayloadLength() + DATA_FRAME_OVERHEAD,false); + ByteBuffer muxPayload = bufferPool.acquire(frame.getPayloadLength() + DATA_FRAME_OVERHEAD,true); BufferUtil.flipToFill(muxPayload); // start building mux payload @@ -90,7 +90,7 @@ public class MuxGenerator return; // nothing to do } - ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,false); + ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,true); BufferUtil.flipToFill(payload); writeChannelId(payload,0); // control channel diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java index 3c5b6b2dd0d..1faab4d4515 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java @@ -404,7 +404,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp { LOG.debug("{} onFillable()",policy.getBehavior()); stats.countOnFillableEvents.incrementAndGet(); - ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); + ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true); BufferUtil.clear(buffer); boolean readMore = false; try diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java index 6eaa773fc8c..bd8192d7199 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java @@ -44,7 +44,7 @@ public class GeneratorParserRoundtripTest String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; - ByteBuffer out = bufferPool.acquire(8192,false); + ByteBuffer out = bufferPool.acquire(8192,true); try { // Generate Buffer @@ -80,7 +80,7 @@ public class GeneratorParserRoundtripTest String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; - ByteBuffer out = bufferPool.acquire(8192,false); + ByteBuffer out = bufferPool.acquire(8192,true); try { // Setup Frame diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java index 9eea24986f9..bc2f3a78113 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java @@ -479,7 +479,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames { LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); - ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); + ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true); BufferUtil.clearToFill(buf); try {