Merge branch 'master' into release-9

This commit is contained in:
Joakim Erdfelt 2013-02-24 07:49:15 -07:00
commit de5c0a3cfe
46 changed files with 168 additions and 158 deletions

View File

@ -24,7 +24,7 @@
<Set name="KeyManagerPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set> <Set name="KeyManagerPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
<Set name="TrustStorePath"><Property name="jetty.home" default="." />/etc/keystore</Set> <Set name="TrustStorePath"><Property name="jetty.home" default="." />/etc/keystore</Set>
<Set name="TrustStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set> <Set name="TrustStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
<Set name="ExcludedCipherSuites"> <Set name="ExcludeCipherSuites">
<Array type="String"> <Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item> <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item> <Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>

View File

@ -55,7 +55,7 @@
<!-- =========================================================== --> <!-- =========================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.util.thread.TimerScheduler.TimerScheduler"/> <New class="org.eclipse.jetty.util.thread.TimerScheduler"/>
</Arg> </Arg>
</Call> </Call>

View File

@ -188,7 +188,7 @@ public class WebSocketClient extends ContainerLifeCycle
cookieStore = new HttpCookieStore.Empty(); cookieStore = new HttpCookieStore.Empty();
} }
this.connectionManager = new ConnectionManager(this); this.connectionManager = newConnectionManager();
addBean(this.connectionManager); addBean(this.connectionManager);
super.doStart(); super.doStart();
@ -300,6 +300,16 @@ public class WebSocketClient extends ContainerLifeCycle
return extensions; return extensions;
} }
/**
* Factory method for new ConnectionManager (used by other projects like cometd)
*
* @return the ConnectionManager instance to use
*/
protected ConnectionManager newConnectionManager()
{
return new ConnectionManager(this);
}
public void setBindAdddress(SocketAddress bindAddress) public void setBindAdddress(SocketAddress bindAddress)
{ {
this.bindAddress = bindAddress; this.bindAddress = bindAddress;

View File

@ -176,7 +176,7 @@ public class ConnectionManager extends ContainerLifeCycle
@Override @Override
protected void doStart() throws Exception protected void doStart() throws Exception
{ {
selector = new WebSocketClientSelectorManager(client.getBufferPool(),client.getExecutor(),client.getScheduler(),client.getPolicy()); selector = newWebSocketClientSelectorManager(client);
selector.setSslContextFactory(client.getSslContextFactory()); selector.setSslContextFactory(client.getSslContextFactory());
selector.setConnectTimeout(client.getConnectTimeout()); selector.setConnectTimeout(client.getConnectTimeout());
addBean(selector); addBean(selector);
@ -209,6 +209,18 @@ public class ConnectionManager extends ContainerLifeCycle
return false; return false;
} }
/**
* Factory method for new WebSocketClientSelectorManager (used by other projects like cometd)
*
* @param client
* the client used to create the WebSocketClientSelectorManager
* @return the new WebSocketClientSelectorManager
*/
protected WebSocketClientSelectorManager newWebSocketClientSelectorManager(WebSocketClient client)
{
return new WebSocketClientSelectorManager(client);
}
public void removeSession(WebSocketSession session) public void removeSession(WebSocketSession session)
{ {
sessions.remove(session); sessions.remove(session);

View File

@ -81,7 +81,7 @@ public class HttpResponseHeaderParser
if (parseHeader(line)) if (parseHeader(line))
{ {
// Finished parsing entire header // Finished parsing entire header
ByteBuffer copy = ByteBuffer.allocate(buf.remaining()); ByteBuffer copy = ByteBuffer.allocateDirect(buf.remaining());
BufferUtil.put(buf,copy); BufferUtil.put(buf,copy);
BufferUtil.flipToFlush(copy,0); BufferUtil.flipToFlush(copy,0);
this.response.setRemainingBuffer(copy); this.response.setRemainingBuffer(copy);

View File

@ -117,7 +117,7 @@ public class UpgradeConnection extends AbstractConnection
@Override @Override
public void onFillable() public void onFillable()
{ {
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
BufferUtil.clear(buffer); BufferUtil.clear(buffer);
boolean readMore = false; boolean readMore = false;
try try

View File

@ -34,7 +34,6 @@ import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -45,17 +44,17 @@ public class WebSocketClientSelectorManager extends SelectorManager
private final ByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private SslContextFactory sslContextFactory; private SslContextFactory sslContextFactory;
public WebSocketClientSelectorManager(ByteBufferPool bufferPool, Executor executor, Scheduler scheduler, WebSocketPolicy policy) public WebSocketClientSelectorManager(WebSocketClient client)
{ {
super(executor,scheduler); super(client.getExecutor(),client.getScheduler());
this.bufferPool = bufferPool; this.bufferPool = client.getBufferPool();
this.policy = policy; this.policy = client.getPolicy();
} }
@Override @Override
protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment) protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
{ {
LOG.info("Connection Failed",ex); LOG.debug("Connection Failed",ex);
ConnectPromise connect = (ConnectPromise)attachment; ConnectPromise connect = (ConnectPromise)attachment;
connect.failed(ex); connect.failed(ex);
} }

View File

@ -72,7 +72,7 @@ public class ServerReadThread extends Thread
public void run() public void run()
{ {
ByteBufferPool bufferPool = conn.getBufferPool(); ByteBufferPool bufferPool = conn.getBufferPool();
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
int len = 0; int len = 0;

View File

@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
@ -103,7 +104,7 @@ public class TomcatServerQuirksTest
// Have server write frame. // Have server write frame.
int length = bufferSize / 2; int length = bufferSize / 2;
ByteBuffer serverFrame = ByteBuffer.allocate(bufferSize); ByteBuffer serverFrame = ByteBuffer.allocateDirect(bufferSize);
serverFrame.put((byte)(0x80 | 0x01)); // FIN + TEXT serverFrame.put((byte)(0x80 | 0x01)); // FIN + TEXT
serverFrame.put((byte)0x7E); // No MASK and 2 bytes length serverFrame.put((byte)0x7E); // No MASK and 2 bytes length
serverFrame.put((byte)(length >> 8)); // first length byte serverFrame.put((byte)(length >> 8)); // first length byte
@ -113,7 +114,7 @@ public class TomcatServerQuirksTest
serverFrame.put((byte)'x'); serverFrame.put((byte)'x');
} }
serverFrame.flip(); serverFrame.flip();
byte buf[] = serverFrame.array(); byte buf[] = BufferUtil.toArray(serverFrame);
socket.write(buf,0,buf.length); socket.write(buf,0,buf.length);
socket.flush(); socket.flush();

View File

@ -310,7 +310,7 @@ public class BlockheadServer
LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); LOG.debug("Read: waiting for {} frame(s) from server",expectedCount);
int startCount = incomingFrames.size(); int startCount = incomingFrames.size();
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
try try
{ {
@ -403,7 +403,7 @@ public class BlockheadServer
{ {
LOG.debug("Entering echo thread"); LOG.debug("Entering echo thread");
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
long readBytes = 0; long readBytes = 0;
try try

View File

@ -64,7 +64,7 @@ public class HttpResponseHeaderParserTest
expected.add(""); expected.add("");
// Prepare Buffer // Prepare Buffer
ByteBuffer buf = ByteBuffer.allocate(512); ByteBuffer buf = ByteBuffer.allocateDirect(512);
for (String line : expected) for (String line : expected)
{ {
appendUtf8(buf,line + "\r\n"); appendUtf8(buf,line + "\r\n");
@ -104,7 +104,7 @@ public class HttpResponseHeaderParserTest
expected.add(""); expected.add("");
// Prepare Buffer // Prepare Buffer
ByteBuffer buf = ByteBuffer.allocate(512); ByteBuffer buf = ByteBuffer.allocateDirect(512);
for (String line : expected) for (String line : expected)
{ {
appendUtf8(buf,line + "\r\n"); appendUtf8(buf,line + "\r\n");

View File

@ -222,7 +222,7 @@ public class Generator
/* /*
* prepare the byte buffer to put frame into * prepare the byte buffer to put frame into
*/ */
ByteBuffer buffer = bufferPool.acquire(windowSize,false); ByteBuffer buffer = bufferPool.acquire(windowSize,true);
BufferUtil.clearToFill(buffer); BufferUtil.clearToFill(buffer);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{ {

View File

@ -553,7 +553,7 @@ public class Parser
if (payload == null) if (payload == null)
{ {
frame.assertValid(); frame.assertValid();
payload = bufferPool.acquire(payloadLength,false); payload = bufferPool.acquire(payloadLength,true);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
} }

View File

@ -83,7 +83,7 @@ public class DeflateCompressionMethod implements CompressionMethod
public ByteBuffer process() public ByteBuffer process()
{ {
// prepare the output buffer // prepare the output buffer
ByteBuffer buf = ByteBuffer.allocate(bufferSize); ByteBuffer buf = ByteBuffer.allocateDirect(bufferSize);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
while (!deflater.finished()) while (!deflater.finished())

View File

@ -57,7 +57,7 @@ public class MuxGenerator
public void generate(long channelId, Frame frame, WriteCallback callback) 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); BufferUtil.flipToFill(muxPayload);
// start building mux payload // start building mux payload
@ -90,7 +90,7 @@ public class MuxGenerator
return; // nothing to do return; // nothing to do
} }
ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,false); ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,true);
BufferUtil.flipToFill(payload); BufferUtil.flipToFill(payload);
writeChannelId(payload,0); // control channel writeChannelId(payload,0); // control channel

View File

@ -243,7 +243,7 @@ public class MuxParser
private void parseDataFramePayload(ByteBuffer buffer) private void parseDataFramePayload(ByteBuffer buffer)
{ {
int capacity = buffer.remaining(); int capacity = buffer.remaining();
ByteBuffer payload = ByteBuffer.allocate(capacity); ByteBuffer payload = ByteBuffer.allocateDirect(capacity);
payload.put(buffer); payload.put(buffer);
BufferUtil.flipToFlush(payload,0); BufferUtil.flipToFlush(payload,0);
muxframe.setPayload(payload); muxframe.setPayload(payload);
@ -336,7 +336,7 @@ public class MuxParser
throw new MuxException(err); throw new MuxException(err);
} }
ByteBuffer ret = ByteBuffer.allocate((int)size); ByteBuffer ret = ByteBuffer.allocateDirect((int)size);
BufferUtil.put(buffer,ret); BufferUtil.put(buffer,ret);
BufferUtil.flipToFlush(ret,0); BufferUtil.flipToFlush(ret,0);
return ret; return ret;

View File

@ -63,7 +63,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override @Override
public void failed(Throwable x) public void failed(Throwable x)
{ {
LOG.warn("Write flush failure",x); LOG.debug("Write flush failure",x);
} }
@Override @Override
@ -404,7 +404,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
{ {
LOG.debug("{} onFillable()",policy.getBehavior()); LOG.debug("{} onFillable()",policy.getBehavior());
stats.countOnFillableEvents.incrementAndGet(); stats.countOnFillableEvents.incrementAndGet();
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
BufferUtil.clear(buffer); BufferUtil.clear(buffer);
boolean readMore = false; boolean readMore = false;
try try

View File

@ -45,7 +45,7 @@ public class MessageInputStream extends InputStream implements MessageAppender
public MessageInputStream(AnnotatedEventDriver driver) public MessageInputStream(AnnotatedEventDriver driver)
{ {
this.driver = driver; this.driver = driver;
this.buf = ByteBuffer.allocate(BUFFER_SIZE); this.buf = ByteBuffer.allocateDirect(BUFFER_SIZE);
BufferUtil.clearToFill(this.buf); BufferUtil.clearToFill(this.buf);
size = 0; size = 0;
readPosition = this.buf.position(); readPosition = this.buf.position();

View File

@ -37,12 +37,12 @@ public class ClosePayloadParserTest
String expectedReason = "Game Over"; String expectedReason = "Game Over";
byte utf[] = expectedReason.getBytes(StringUtil.__UTF8_CHARSET); 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.putChar((char)StatusCode.NORMAL);
payload.put(utf,0,utf.length); payload.put(utf,0,utf.length);
payload.flip(); payload.flip();
ByteBuffer buf = ByteBuffer.allocate(24); ByteBuffer buf = ByteBuffer.allocateDirect(24);
buf.put((byte)(0x80 | OpCode.CLOSE)); // fin + close buf.put((byte)(0x80 | OpCode.CLOSE)); // fin + close
buf.put((byte)(0x80 | payload.remaining())); buf.put((byte)(0x80 | payload.remaining()));
MaskedByteBuffer.putMask(buf); MaskedByteBuffer.putMask(buf);

View File

@ -44,7 +44,7 @@ public class GeneratorParserRoundtripTest
String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
ByteBuffer out = bufferPool.acquire(8192,false); ByteBuffer out = bufferPool.acquire(8192,true);
try try
{ {
// Generate Buffer // Generate Buffer
@ -80,7 +80,7 @@ public class GeneratorParserRoundtripTest
String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
ByteBuffer out = bufferPool.acquire(8192,false); ByteBuffer out = bufferPool.acquire(8192,true);
try try
{ {
// Setup Frame // Setup Frame

View File

@ -139,7 +139,7 @@ public class GeneratorTest
// Buffer to capture generated bytes (we do this to validate that the masking // Buffer to capture generated bytes (we do this to validate that the masking
// is working correctly // is working correctly
ByteBuffer completeBuf = ByteBuffer.allocate(payload.length + expectedHeaderSize); ByteBuffer completeBuf = ByteBuffer.allocateDirect(payload.length + expectedHeaderSize);
BufferUtil.clearToFill(completeBuf); BufferUtil.clearToFill(completeBuf);
// Generate and capture generator output // Generate and capture generator output

View File

@ -191,7 +191,7 @@ public class ParserTest
@Test @Test
public void testParseCase6_4_3() public void testParseCase6_4_3()
{ {
ByteBuffer payload = ByteBuffer.allocate(64); ByteBuffer payload = ByteBuffer.allocateDirect(64);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good
payload.put(TypeUtil.fromHexString("f4908080")); // INVALID payload.put(TypeUtil.fromHexString("f4908080")); // INVALID
@ -205,9 +205,9 @@ public class ParserTest
ByteBuffer buf = new UnitGenerator().generate(text); ByteBuffer buf = new UnitGenerator().generate(text);
ByteBuffer part1 = ByteBuffer.allocate(17); // header + good ByteBuffer part1 = ByteBuffer.allocateDirect(17); // header + good
ByteBuffer part2 = ByteBuffer.allocate(4); // invalid ByteBuffer part2 = ByteBuffer.allocateDirect(4); // invalid
ByteBuffer part3 = ByteBuffer.allocate(10); // the rest (all good utf) ByteBuffer part3 = ByteBuffer.allocateDirect(10); // the rest (all good utf)
BufferUtil.put(buf,part1); BufferUtil.put(buf,part1);
BufferUtil.put(buf,part2); BufferUtil.put(buf,part2);
@ -235,7 +235,7 @@ public class ParserTest
@Test @Test
public void testParseNothing() public void testParseNothing()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
// Put nothing in the buffer. // Put nothing in the buffer.
buf.flip(); buf.flip();

View File

@ -33,7 +33,7 @@ public class PingPayloadParserTest
@Test @Test
public void testBasicPingParsing() public void testBasicPingParsing()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
buf.put(new byte[] buf.put(new byte[]
{ (byte)0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f }); { (byte)0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f });

View File

@ -21,9 +21,6 @@ package org.eclipse.jetty.websocket.common;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; 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; import org.junit.Test;
public class RFC6455ExamplesGeneratorTest public class RFC6455ExamplesGeneratorTest
@ -41,12 +38,12 @@ public class RFC6455ExamplesGeneratorTest
ByteBuffer actual1 = generator.generate(text1); ByteBuffer actual1 = generator.generate(text1);
ByteBuffer actual2 = generator.generate(text2); ByteBuffer actual2 = generator.generate(text2);
ByteBuffer expected1 = ByteBuffer.allocate(5); ByteBuffer expected1 = ByteBuffer.allocateDirect(5);
expected1.put(new byte[] expected1.put(new byte[]
{ (byte)0x01, (byte)0x03, (byte)0x48, (byte)0x65, (byte)0x6c }); { (byte)0x01, (byte)0x03, (byte)0x48, (byte)0x65, (byte)0x6c });
ByteBuffer expected2 = ByteBuffer.allocate(4); ByteBuffer expected2 = ByteBuffer.allocateDirect(4);
expected2.put(new byte[] expected2.put(new byte[]
{ (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f }); { (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f });
@ -70,7 +67,7 @@ public class RFC6455ExamplesGeneratorTest
ByteBuffer actual = gen.generate(pong); 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// Unmasked Pong request // Unmasked Pong request
expected.put(new byte[] expected.put(new byte[]
@ -90,7 +87,7 @@ public class RFC6455ExamplesGeneratorTest
Generator gen = new UnitGenerator(); Generator gen = new UnitGenerator();
ByteBuffer actual = gen.generate(text); 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// A single-frame masked text message // A single-frame masked text message
expected.put(new byte[] expected.put(new byte[]
@ -114,7 +111,7 @@ public class RFC6455ExamplesGeneratorTest
ByteBuffer actual = gen.generate(binary); 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// 256 bytes binary message in a single unmasked frame // 256 bytes binary message in a single unmasked frame
expected.put(new byte[] expected.put(new byte[]
@ -145,7 +142,7 @@ public class RFC6455ExamplesGeneratorTest
ByteBuffer actual = gen.generate(binary); 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// 64k bytes binary message in a single unmasked frame // 64k bytes binary message in a single unmasked frame
expected.put(new byte[] expected.put(new byte[]
@ -171,7 +168,7 @@ public class RFC6455ExamplesGeneratorTest
Generator gen = new UnitGenerator(); Generator gen = new UnitGenerator();
ByteBuffer actual = gen.generate(ping); ByteBuffer actual = gen.generate(ping);
ByteBuffer expected = ByteBuffer.allocate(10); ByteBuffer expected = ByteBuffer.allocateDirect(10);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f }); { (byte)0x89, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });
expected.flip(); // make readable expected.flip(); // make readable
@ -188,7 +185,7 @@ public class RFC6455ExamplesGeneratorTest
ByteBuffer actual = generator.generate(text); ByteBuffer actual = generator.generate(text);
ByteBuffer expected = ByteBuffer.allocate(10); ByteBuffer expected = ByteBuffer.allocateDirect(10);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f }); { (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });

View File

@ -42,7 +42,7 @@ public class RFC6455ExamplesParserTest
IncomingFramesCapture capture = new IncomingFramesCapture(); IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture); parser.setIncomingFramesHandler(capture);
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
// Raw bytes as found in RFC 6455, Section 5.7 - Examples // Raw bytes as found in RFC 6455, Section 5.7 - Examples
@ -75,7 +75,7 @@ public class RFC6455ExamplesParserTest
@Test @Test
public void testSingleMaskedPongRequest() public void testSingleMaskedPongRequest()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
// Raw bytes as found in RFC 6455, Section 5.7 - Examples // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// Unmasked Pong request // Unmasked Pong request
buf.put(new byte[] buf.put(new byte[]
@ -98,7 +98,7 @@ public class RFC6455ExamplesParserTest
@Test @Test
public void testSingleMaskedTextMessage() public void testSingleMaskedTextMessage()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
// Raw bytes as found in RFC 6455, Section 5.7 - Examples // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// A single-frame masked text message // A single-frame masked text message
buf.put(new byte[] buf.put(new byte[]
@ -123,7 +123,7 @@ public class RFC6455ExamplesParserTest
{ {
int dataSize = 256; 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// 256 bytes binary message in a single unmasked frame // 256 bytes binary message in a single unmasked frame
buf.put(new byte[] buf.put(new byte[]
@ -162,7 +162,7 @@ public class RFC6455ExamplesParserTest
{ {
int dataSize = 1024 * 64; 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 // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// 64 Kbytes binary message in a single unmasked frame // 64 Kbytes binary message in a single unmasked frame
buf.put(new byte[] buf.put(new byte[]
@ -198,7 +198,7 @@ public class RFC6455ExamplesParserTest
@Test @Test
public void testSingleUnmaskedPingRequest() public void testSingleUnmaskedPingRequest()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
// Raw bytes as found in RFC 6455, Section 5.7 - Examples // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// Unmasked Ping request // Unmasked Ping request
buf.put(new byte[] buf.put(new byte[]
@ -221,7 +221,7 @@ public class RFC6455ExamplesParserTest
@Test @Test
public void testSingleUnmaskedTextMessage() public void testSingleUnmaskedTextMessage()
{ {
ByteBuffer buf = ByteBuffer.allocate(16); ByteBuffer buf = ByteBuffer.allocateDirect(16);
// Raw bytes as found in RFC 6455, Section 5.7 - Examples // Raw bytes as found in RFC 6455, Section 5.7 - Examples
// A single-frame unmasked text message // A single-frame unmasked text message
buf.put(new byte[] buf.put(new byte[]

View File

@ -44,7 +44,7 @@ public class TextPayloadParserTest
Assert.assertThat("Must be a medium length payload",utf.length,allOf(greaterThan(0x7E),lessThan(0xFFFF))); 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)0x81);
buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length) buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length)
buf.putShort((short)utf.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)); 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)0x81);
buf.put((byte)(0x80 | 0x7F)); // 0x7F == 127 (a 8 byte payload length) buf.put((byte)(0x80 | 0x7F)); // 0x7F == 127 (a 8 byte payload length)
buf.putLong(utf.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))); 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)0x81);
buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length) buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length)
buf.putShort((short)utf.length); buf.putShort((short)utf.length);
@ -144,7 +144,7 @@ public class TextPayloadParserTest
byte b1[] = part1.getBytes(StringUtil.__UTF8_CHARSET); byte b1[] = part1.getBytes(StringUtil.__UTF8_CHARSET);
byte b2[] = part2.getBytes(StringUtil.__UTF8_CHARSET); byte b2[] = part2.getBytes(StringUtil.__UTF8_CHARSET);
ByteBuffer buf = ByteBuffer.allocate(32); ByteBuffer buf = ByteBuffer.allocateDirect(32);
// part 1 // part 1
buf.put((byte)0x01); // no fin + text buf.put((byte)0x01); // no fin + text
@ -180,7 +180,7 @@ public class TextPayloadParserTest
String expectedText = "Hello World"; String expectedText = "Hello World";
byte utf[] = expectedText.getBytes(StringUtil.__UTF8_CHARSET); byte utf[] = expectedText.getBytes(StringUtil.__UTF8_CHARSET);
ByteBuffer buf = ByteBuffer.allocate(24); ByteBuffer buf = ByteBuffer.allocateDirect(24);
buf.put((byte)0x81); buf.put((byte)0x81);
buf.put((byte)(0x80 | utf.length)); buf.put((byte)(0x80 | utf.length));
MaskedByteBuffer.putMask(buf); MaskedByteBuffer.putMask(buf);
@ -206,7 +206,7 @@ public class TextPayloadParserTest
byte utf[] = expectedText.getBytes(StringUtil.__UTF8); byte utf[] = expectedText.getBytes(StringUtil.__UTF8);
ByteBuffer buf = ByteBuffer.allocate(24); ByteBuffer buf = ByteBuffer.allocateDirect(24);
buf.put((byte)0x81); buf.put((byte)0x81);
buf.put((byte)(0x80 | utf.length)); buf.put((byte)(0x80 | utf.length));
MaskedByteBuffer.putMask(buf); MaskedByteBuffer.putMask(buf);

View File

@ -46,7 +46,7 @@ public class UnitGenerator extends Generator
{ {
buflen += f.getPayloadLength() + Generator.OVERHEAD; buflen += f.getPayloadLength() + Generator.OVERHEAD;
} }
ByteBuffer completeBuf = ByteBuffer.allocate(buflen); ByteBuffer completeBuf = ByteBuffer.allocateDirect(buflen);
BufferUtil.clearToFill(completeBuf); BufferUtil.clearToFill(completeBuf);
// Generate frames // Generate frames

View File

@ -58,7 +58,7 @@ public class WebSocketFrameTest
{ {
WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE).setFin(false); WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE).setFin(false);
ByteBuffer actual = laxGenerator.generate(frame); ByteBuffer actual = laxGenerator.generate(frame);
ByteBuffer expected = ByteBuffer.allocate(2); ByteBuffer expected = ByteBuffer.allocateDirect(2);
expected.put((byte)0x08); expected.put((byte)0x08);
expected.put((byte)0x00); expected.put((byte)0x00);
@ -70,7 +70,7 @@ public class WebSocketFrameTest
{ {
WebSocketFrame frame = new WebSocketFrame(OpCode.PING).setFin(false); WebSocketFrame frame = new WebSocketFrame(OpCode.PING).setFin(false);
ByteBuffer actual = laxGenerator.generate(frame); ByteBuffer actual = laxGenerator.generate(frame);
ByteBuffer expected = ByteBuffer.allocate(2); ByteBuffer expected = ByteBuffer.allocateDirect(2);
expected.put((byte)0x09); expected.put((byte)0x09);
expected.put((byte)0x00); expected.put((byte)0x00);
@ -82,7 +82,7 @@ public class WebSocketFrameTest
{ {
CloseInfo close = new CloseInfo(StatusCode.NORMAL); CloseInfo close = new CloseInfo(StatusCode.NORMAL);
ByteBuffer actual = strictGenerator.generate(close.asFrame()); ByteBuffer actual = strictGenerator.generate(close.asFrame());
ByteBuffer expected = ByteBuffer.allocate(4); ByteBuffer expected = ByteBuffer.allocateDirect(4);
expected.put((byte)0x88); expected.put((byte)0x88);
expected.put((byte)0x02); expected.put((byte)0x02);
expected.put((byte)0x03); expected.put((byte)0x03);
@ -96,7 +96,7 @@ public class WebSocketFrameTest
{ {
WebSocketFrame frame = new WebSocketFrame(OpCode.PING); WebSocketFrame frame = new WebSocketFrame(OpCode.PING);
ByteBuffer actual = strictGenerator.generate(frame); ByteBuffer actual = strictGenerator.generate(frame);
ByteBuffer expected = ByteBuffer.allocate(2); ByteBuffer expected = ByteBuffer.allocateDirect(2);
expected.put((byte)0x89); expected.put((byte)0x89);
expected.put((byte)0x00); expected.put((byte)0x00);

View File

@ -60,7 +60,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -96,7 +96,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -136,7 +136,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -176,7 +176,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -217,7 +217,7 @@ public class TestABCase1_1
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -255,7 +255,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 11); ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -284,7 +284,7 @@ public class TestABCase1_1
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(textFrame); ByteBuffer actual = generator.generate(textFrame);
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81, (byte)0x00 }); { (byte)0x81, (byte)0x00 });
@ -299,7 +299,7 @@ public class TestABCase1_1
{ {
int length = 125; int length = 125;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -332,7 +332,7 @@ public class TestABCase1_1
{ {
int length = 126; int length = 126;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -366,7 +366,7 @@ public class TestABCase1_1
{ {
int length = 127; int length = 127;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -400,7 +400,7 @@ public class TestABCase1_1
{ {
int length = 128; int length = 128;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -434,7 +434,7 @@ public class TestABCase1_1
{ {
int length = 65535; int length = 65535;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -470,7 +470,7 @@ public class TestABCase1_1
{ {
int length = 65536; int length = 65536;
ByteBuffer expected = ByteBuffer.allocate(length + 11); ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81 }); { (byte)0x81 });
@ -506,7 +506,7 @@ public class TestABCase1_1
public void testParseEmptyTextCase1_1_1() public void testParseEmptyTextCase1_1_1()
{ {
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x81, (byte)0x00 }); { (byte)0x81, (byte)0x00 });

View File

@ -49,7 +49,7 @@ public class TestABCase1_2
{ {
int length = 125; int length = 125;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -64,7 +64,7 @@ public class TestABCase1_2
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -88,7 +88,7 @@ public class TestABCase1_2
{ {
int length = 126; int length = 126;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -102,7 +102,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -130,7 +130,7 @@ public class TestABCase1_2
{ {
int length = 127; int length = 127;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -145,7 +145,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -173,7 +173,7 @@ public class TestABCase1_2
{ {
int length = 128; int length = 128;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -187,7 +187,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -216,7 +216,7 @@ public class TestABCase1_2
{ {
int length = 65535; int length = 65535;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -231,7 +231,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -256,7 +256,7 @@ public class TestABCase1_2
{ {
int length = 65536; int length = 65536;
ByteBuffer bb = ByteBuffer.allocate(length); ByteBuffer bb = ByteBuffer.allocateDirect(length);
for ( int i = 0 ; i < length ; ++i) for ( int i = 0 ; i < length ; ++i)
{ {
@ -271,7 +271,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(length + 11); ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -300,7 +300,7 @@ public class TestABCase1_2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(binaryFrame); ByteBuffer actual = generator.generate(binaryFrame);
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82, (byte)0x00 }); { (byte)0x82, (byte)0x00 });
@ -315,7 +315,7 @@ public class TestABCase1_2
{ {
int length = 125; int length = 125;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -348,7 +348,7 @@ public class TestABCase1_2
{ {
int length = 126; int length = 126;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -382,7 +382,7 @@ public class TestABCase1_2
{ {
int length = 127; int length = 127;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -416,7 +416,7 @@ public class TestABCase1_2
{ {
int length = 128; int length = 128;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -450,7 +450,7 @@ public class TestABCase1_2
{ {
int length = 65535; int length = 65535;
ByteBuffer expected = ByteBuffer.allocate(length + 5); ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -486,7 +486,7 @@ public class TestABCase1_2
{ {
int length = 65536; int length = 65536;
ByteBuffer expected = ByteBuffer.allocate(length + 11); ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82 }); { (byte)0x82 });
@ -521,7 +521,7 @@ public class TestABCase1_2
public void testParseEmptyBinaryCase1_2_1() public void testParseEmptyBinaryCase1_2_1()
{ {
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x82, (byte)0x00 }); { (byte)0x82, (byte)0x00 });

View File

@ -58,7 +58,7 @@ public class TestABCase2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(pingFrame); ByteBuffer actual = generator.generate(pingFrame);
ByteBuffer expected = ByteBuffer.allocate(bytes.length + 32); ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + 32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -83,7 +83,7 @@ public class TestABCase2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(pingFrame); ByteBuffer actual = generator.generate(pingFrame);
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -108,7 +108,7 @@ public class TestABCase2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(pingFrame); ByteBuffer actual = generator.generate(pingFrame);
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89, (byte)0x00 }); { (byte)0x89, (byte)0x00 });
@ -129,7 +129,7 @@ public class TestABCase2
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(pingFrame); ByteBuffer actual = generator.generate(pingFrame);
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -183,7 +183,7 @@ public class TestABCase2
bytes[i] = Integer.valueOf(Integer.toOctalString(i)).byteValue(); 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[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -213,7 +213,7 @@ public class TestABCase2
{ {
byte[] bytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; 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[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -241,7 +241,7 @@ public class TestABCase2
@Test @Test
public void testParseEmptyPingCase2_1() public void testParseEmptyPingCase2_1()
{ {
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89, (byte)0x00 }); { (byte)0x89, (byte)0x00 });
@ -267,7 +267,7 @@ public class TestABCase2
String message = "Hello, world!"; String message = "Hello, world!";
byte[] messageBytes = message.getBytes(); byte[] messageBytes = message.getBytes();
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x89 }); { (byte)0x89 });
@ -298,7 +298,7 @@ public class TestABCase2
byte[] bytes = new byte[126]; byte[] bytes = new byte[126];
Arrays.fill(bytes,(byte)0x00); Arrays.fill(bytes,(byte)0x00);
ByteBuffer expected = ByteBuffer.allocate(bytes.length + Generator.OVERHEAD); ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + Generator.OVERHEAD);
byte b; byte b;

View File

@ -51,7 +51,7 @@ public class TestABCase4
@Test @Test
public void testParserControlOpCode11Case4_2_1() public void testParserControlOpCode11Case4_2_1()
{ {
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x8b, 0x00 }); { (byte)0x8b, 0x00 });
@ -73,7 +73,7 @@ public class TestABCase4
@Test @Test
public void testParserControlOpCode12WithPayloadCase4_2_2() public void testParserControlOpCode12WithPayloadCase4_2_2()
{ {
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x8c, 0x01, 0x00 }); { (byte)0x8c, 0x01, 0x00 });
@ -96,7 +96,7 @@ public class TestABCase4
@Test @Test
public void testParserNonControlOpCode3Case4_1_1() public void testParserNonControlOpCode3Case4_1_1()
{ {
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x83, 0x00 }); { (byte)0x83, 0x00 });
@ -118,7 +118,7 @@ public class TestABCase4
@Test @Test
public void testParserNonControlOpCode4WithPayloadCase4_1_2() public void testParserNonControlOpCode4WithPayloadCase4_1_2()
{ {
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x84, 0x01, 0x00 }); { (byte)0x84, 0x01, 0x00 });

View File

@ -53,7 +53,7 @@ public class TestABCase7_3
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(close.asFrame()); ByteBuffer actual = generator.generate(close.asFrame());
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88, (byte)0x00 }); { (byte)0x88, (byte)0x00 });
@ -66,7 +66,7 @@ public class TestABCase7_3
@Test @Test
public void testCase7_3_1ParseEmptyClose() public void testCase7_3_1ParseEmptyClose()
{ {
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88, (byte)0x00 }); { (byte)0x88, (byte)0x00 });
@ -100,7 +100,7 @@ public class TestABCase7_3
@Test @Test
public void testCase7_3_2Parse1BytePayloadClose() public void testCase7_3_2Parse1BytePayloadClose()
{ {
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88, 0x01, 0x00 }); { (byte)0x88, 0x01, 0x00 });
@ -127,7 +127,7 @@ public class TestABCase7_3
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(close.asFrame()); ByteBuffer actual = generator.generate(close.asFrame());
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 }); { (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
@ -140,7 +140,7 @@ public class TestABCase7_3
@Test @Test
public void testCase7_3_3ParseCloseWithStatus() public void testCase7_3_3ParseCloseWithStatus()
{ {
ByteBuffer expected = ByteBuffer.allocate(5); ByteBuffer expected = ByteBuffer.allocateDirect(5);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 }); { (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
@ -172,7 +172,7 @@ public class TestABCase7_3
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(close.asFrame()); ByteBuffer actual = generator.generate(close.asFrame());
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88 }); { (byte)0x88 });
@ -194,7 +194,7 @@ public class TestABCase7_3
String message = "bad cough"; String message = "bad cough";
byte[] messageBytes = message.getBytes(); byte[] messageBytes = message.getBytes();
ByteBuffer expected = ByteBuffer.allocate(32); ByteBuffer expected = ByteBuffer.allocateDirect(32);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88 }); { (byte)0x88 });
@ -232,7 +232,7 @@ public class TestABCase7_3
Generator generator = new UnitGenerator(); Generator generator = new UnitGenerator();
ByteBuffer actual = generator.generate(close.asFrame()); ByteBuffer actual = generator.generate(close.asFrame());
ByteBuffer expected = ByteBuffer.allocate(132); ByteBuffer expected = ByteBuffer.allocateDirect(132);
byte messageBytes[] = message.toString().getBytes(StringUtil.__UTF8_CHARSET); byte messageBytes[] = message.toString().getBytes(StringUtil.__UTF8_CHARSET);
@ -262,7 +262,7 @@ public class TestABCase7_3
byte[] messageBytes = message.toString().getBytes(StringUtil.__UTF8_CHARSET); byte[] messageBytes = message.toString().getBytes(StringUtil.__UTF8_CHARSET);
ByteBuffer expected = ByteBuffer.allocate(132); ByteBuffer expected = ByteBuffer.allocateDirect(132);
expected.put(new byte[] expected.put(new byte[]
{ (byte)0x88 }); { (byte)0x88 });
@ -301,7 +301,7 @@ public class TestABCase7_3
WebSocketFrame closeFrame = new WebSocketFrame(OpCode.CLOSE); 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.putChar((char)1000);
bb.put(messageBytes); bb.put(messageBytes);
@ -320,7 +320,7 @@ public class TestABCase7_3
byte[] messageBytes = new byte[124]; byte[] messageBytes = new byte[124];
Arrays.fill(messageBytes,(byte)'*'); Arrays.fill(messageBytes,(byte)'*');
ByteBuffer expected = ByteBuffer.allocate(256); ByteBuffer expected = ByteBuffer.allocateDirect(256);
byte b; byte b;

View File

@ -56,7 +56,7 @@ public class DeflateCompressionMethodTest
method.compress().end(); method.compress().end();
// decompress // decompress
ByteBuffer decompressed = ByteBuffer.allocate(msg.length()); ByteBuffer decompressed = ByteBuffer.allocateDirect(msg.length());
LOG.debug("decompressed(a): {}",BufferUtil.toDetailString(decompressed)); LOG.debug("decompressed(a): {}",BufferUtil.toDetailString(decompressed));
method.decompress().begin(); method.decompress().begin();
method.decompress().input(compressed); method.decompress().input(compressed);
@ -89,7 +89,7 @@ public class DeflateCompressionMethodTest
CompressionMethod method = new DeflateCompressionMethod(); CompressionMethod method = new DeflateCompressionMethod();
// Decompressed Data Holder // Decompressed Data Holder
ByteBuffer decompressed = ByteBuffer.allocate(32); ByteBuffer decompressed = ByteBuffer.allocateDirect(32);
BufferUtil.flipToFill(decompressed); BufferUtil.flipToFill(decompressed);
// Perform Decompress on Buf 1 // Perform Decompress on Buf 1

View File

@ -179,7 +179,7 @@ public class FrameCompressionExtensionTest
compressor.finish(); compressor.finish();
// Perform compression // Perform compression
ByteBuffer outbuf = ByteBuffer.allocate(64); ByteBuffer outbuf = ByteBuffer.allocateDirect(64);
BufferUtil.clearToFill(outbuf); BufferUtil.clearToFill(outbuf);
while (!compressor.finished()) while (!compressor.finished())

View File

@ -88,7 +88,7 @@ public class MuxGeneratorWrite139SizeTest
public void testWrite139Size() public void testWrite139Size()
{ {
System.err.printf("Running %s.%s - value: %,d%n",this.getClass().getName(),testname.getMethodName(),value); 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); generator.write139Size(bbuf,value);
BufferUtil.flipToFlush(bbuf,0); BufferUtil.flipToFlush(bbuf,0);
byte actual[] = BufferUtil.toArray(bbuf); byte actual[] = BufferUtil.toArray(bbuf);

View File

@ -92,7 +92,7 @@ public class MuxGeneratorWriteChannelIdTest
public void testReadChannelId() public void testReadChannelId()
{ {
System.err.printf("Running %s.%s - channelId: %,d%n",this.getClass().getName(),testname.getMethodName(),channelId); 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); generator.writeChannelId(bbuf,channelId);
BufferUtil.flipToFlush(bbuf,0); BufferUtil.flipToFlush(bbuf,0);
byte actual[] = BufferUtil.toArray(bbuf); byte actual[] = BufferUtil.toArray(bbuf);

View File

@ -101,7 +101,7 @@ public class Fuzzer
{ {
buflen += f.getPayloadLength() + Generator.OVERHEAD; buflen += f.getPayloadLength() + Generator.OVERHEAD;
} }
ByteBuffer buf = ByteBuffer.allocate(buflen); ByteBuffer buf = ByteBuffer.allocateDirect(buflen);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
// Generate frames // Generate frames
@ -271,7 +271,7 @@ public class Fuzzer
{ {
buflen += f.getPayloadLength() + Generator.OVERHEAD; buflen += f.getPayloadLength() + Generator.OVERHEAD;
} }
ByteBuffer buf = ByteBuffer.allocate(buflen); ByteBuffer buf = ByteBuffer.allocateDirect(buflen);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
// Generate frames // Generate frames

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.server.ab;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.AdvancedRunner; import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.annotation.Slow; import org.eclipse.jetty.toolchain.test.annotation.Slow;
@ -299,9 +298,7 @@ public class TestABCase6 extends AbstractABCase
fuzzer.setSendMode(Fuzzer.SendMode.BULK); fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false)); fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false)); 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.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true));
fuzzer.expect(expect); fuzzer.expect(expect);
@ -338,9 +335,7 @@ public class TestABCase6 extends AbstractABCase
fuzzer.connect(); fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK); fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false)); fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false)); 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.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true));
fuzzer.expect(expect); 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) // Disable Long Stacks from Parser (we know this test will throw an exception)
enableStacks(Parser.class,false); enableStacks(Parser.class,false);
ByteBuffer payload = ByteBuffer.allocate(64); ByteBuffer payload = ByteBuffer.allocateDirect(64);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good
payload.put(TypeUtil.fromHexString("f4908080")); // INVALID payload.put(TypeUtil.fromHexString("f4908080")); // INVALID
@ -394,12 +389,10 @@ public class TestABCase6 extends AbstractABCase
part3.limit(splits[2]); part3.limit(splits[2]);
fuzzer.send(part1); // the header + good utf fuzzer.send(part1); // the header + good utf
TimeUnit.SECONDS.sleep(1);
fuzzer.send(part2); // the bad UTF fuzzer.send(part2); // the bad UTF
fuzzer.expect(expect); fuzzer.expect(expect);
TimeUnit.SECONDS.sleep(1);
fuzzer.sendExpectingIOException(part3); // the rest (shouldn't work) fuzzer.sendExpectingIOException(part3); // the rest (shouldn't work)
} }
finally finally
@ -436,9 +429,7 @@ public class TestABCase6 extends AbstractABCase
ByteBuffer net = fuzzer.asNetworkBuffer(send); ByteBuffer net = fuzzer.asNetworkBuffer(send);
fuzzer.send(net,6); fuzzer.send(net,6);
fuzzer.send(net,11); fuzzer.send(net,11);
TimeUnit.SECONDS.sleep(1);
fuzzer.send(net,1); fuzzer.send(net,1);
TimeUnit.SECONDS.sleep(1);
fuzzer.send(net,100); // the rest fuzzer.send(net,100); // the rest
fuzzer.expect(expect); fuzzer.expect(expect);

View File

@ -367,7 +367,7 @@ public class TestABCase7 extends AbstractABCase
@Test @Test
public void testCase7_3_6() throws Exception public void testCase7_3_6() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.put((byte)0xE8); payload.put((byte)0xE8);
payload.put((byte)0x03); payload.put((byte)0x03);
@ -408,7 +408,7 @@ public class TestABCase7 extends AbstractABCase
@Test @Test
public void testCase7_5_1() throws Exception public void testCase7_5_1() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.put((byte)0x03); // normal close payload.put((byte)0x03); // normal close
payload.put((byte)0xE8); payload.put((byte)0xE8);

View File

@ -86,7 +86,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase
@Test @Test
public void testBadStatusCode() throws Exception public void testBadStatusCode() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.putChar((char)statusCode); payload.putChar((char)statusCode);
BufferUtil.flipToFlush(payload,0); BufferUtil.flipToFlush(payload,0);
@ -118,7 +118,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase
@Test @Test
public void testBadStatusCodeWithReason() throws Exception public void testBadStatusCodeWithReason() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.putChar((char)statusCode); payload.putChar((char)statusCode);
payload.put(StringUtil.getBytes("Reason")); payload.put(StringUtil.getBytes("Reason"));

View File

@ -81,7 +81,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase
@Test @Test
public void testStatusCode() throws Exception public void testStatusCode() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.putChar((char)statusCode); payload.putChar((char)statusCode);
BufferUtil.flipToFlush(payload,0); BufferUtil.flipToFlush(payload,0);
@ -113,7 +113,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase
@Test @Test
public void testStatusCodeWithReason() throws Exception public void testStatusCodeWithReason() throws Exception
{ {
ByteBuffer payload = ByteBuffer.allocate(256); ByteBuffer payload = ByteBuffer.allocateDirect(256);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
payload.putChar((char)statusCode); payload.putChar((char)statusCode);
payload.put(StringUtil.getBytes("Reason")); payload.put(StringUtil.getBytes("Reason"));

View File

@ -479,7 +479,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames
{ {
LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); 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); BufferUtil.clearToFill(buf);
try try
{ {

View File

@ -46,7 +46,7 @@ public class EchoBroadcastPingSocket extends EchoBroadcastSocket
while (!latch.await(10,TimeUnit.SECONDS)) while (!latch.await(10,TimeUnit.SECONDS))
{ {
System.err.println("Ping"); System.err.println("Ping");
ByteBuffer data = ByteBuffer.allocate(3); ByteBuffer data = ByteBuffer.allocateDirect(3);
data.put(new byte[] data.put(new byte[]
{ (byte)1, (byte)2, (byte)3 }); { (byte)1, (byte)2, (byte)3 });
data.flip(); data.flip();

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.server.helper; package org.eclipse.jetty.websocket.server.helper;
import static org.hamcrest.Matchers.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -34,8 +36,6 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
import org.junit.Assert; import org.junit.Assert;
import static org.hamcrest.Matchers.is;
public class SafariD00 public class SafariD00
{ {
private URI uri; private URI uri;
@ -52,7 +52,7 @@ public class SafariD00
/** /**
* Open the Socket to the destination endpoint and * Open the Socket to the destination endpoint and
* *
* @return the open java Socket. * @return the open java Socket.
* @throws IOException * @throws IOException
*/ */
@ -74,7 +74,7 @@ public class SafariD00
/** /**
* Issue an Http websocket (Draft-0) upgrade request using the Safari particulars. * Issue an Http websocket (Draft-0) upgrade request using the Safari particulars.
* *
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
*/ */
public void issueHandshake() throws IOException public void issueHandshake() throws IOException
@ -135,7 +135,7 @@ public class SafariD00
len += (msg.length() + 2); len += (msg.length() + 2);
} }
ByteBuffer buf = ByteBuffer.allocate(len); ByteBuffer buf = ByteBuffer.allocateDirect(len);
for (String msg : msgs) for (String msg : msgs)
{ {

View File

@ -400,7 +400,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId> <artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version> <version>2.5.2</version>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>