Fixing bad generator.generate() assumptions on output bytebuffer state

This commit is contained in:
Joakim Erdfelt 2012-07-18 12:36:42 -07:00
parent b0e475f09c
commit 1c77ef0723
4 changed files with 3 additions and 11 deletions

View File

@ -17,7 +17,6 @@ package org.eclipse.jetty.websocket.io;
import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.websocket.protocol.OpCode;
import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
@ -50,7 +49,6 @@ public class ControlFrameBytes<C> extends FrameBytes<C>
if (buffer == null)
{
buffer = connection.getGenerator().generate(frame);
BufferUtil.flipToFlush(buffer,0);
}
return buffer;
}

View File

@ -17,7 +17,6 @@ package org.eclipse.jetty.websocket.io;
import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -46,9 +45,9 @@ public class DataFrameBytes<C> extends FrameBytes<C>
if (frame.remaining() > 0)
{
// We have written a frame out of this DataInfo, but there is more to write.
// We have written a partial frame per windowing size.
// We need to keep the correct ordering of frames, to avoid that another
// DataInfo for the same stream is written before this one is finished.
// Data frame for the same stream is written before this one is finished.
connection.getQueue().prepend(this);
}
else
@ -72,7 +71,6 @@ public class DataFrameBytes<C> extends FrameBytes<C>
}
buffer = connection.getGenerator().generate(size,frame);
BufferUtil.flipToFlush(buffer,0);
return buffer;
}
catch (Throwable x)

View File

@ -78,7 +78,7 @@ public class TestABCase5
// echo the message back.
try
{
getConnection().write(null,new FutureCallback<Void>(),message);
getConnection().write("ECHO_FROM_WEBSOCKET",new FutureCallback<String>(),message);
}
catch (IOException e)
{
@ -434,21 +434,18 @@ public class TestABCase5
String textPayload1 = "fragment1";
WebSocketFrame frame1 = WebSocketFrame.text().setFin(false).setPayload(textPayload1);
ByteBuffer buf1 = laxGenerator.generate(frame1);
BufferUtil.flipToFlush(buf1,0);
client.writeRaw(buf1);
// Send a ping with payload
String pingPayload = "ping payload";
WebSocketFrame frame2 = WebSocketFrame.ping().setPayload(pingPayload);
ByteBuffer buf2 = laxGenerator.generate(frame2);
BufferUtil.flipToFlush(buf2,0);
client.writeRaw(buf2);
// Send remaining text as continuation
String textPayload2 = "fragment2";
WebSocketFrame frame3 = new WebSocketFrame(OpCode.CONTINUATION).setPayload(textPayload2);
ByteBuffer buf3 = laxGenerator.generate(frame3);
BufferUtil.flipToFlush(buf3,0);
client.writeRaw(buf3);
// Should be 2 frames, pong frame followed by combined echo'd text frame

View File

@ -412,7 +412,6 @@ public class BlockheadClient implements IncomingFrames
frame.setMask(clientmask);
// frame.setMask(new byte[] { 0x00, 0x00, 0x00, 0x00 });
ByteBuffer buf = generator.generate(frame);
BufferUtil.flipToFlush(buf,0);
if (LOG.isDebugEnabled())
{
LOG.debug("writing out: {}",BufferUtil.toDetailString(buf));