400255 - Using WebSocket.maxMessageSize results in IllegalArgumentException

This commit is contained in:
Joakim Erdfelt 2013-02-11 16:24:13 -07:00
parent ade135ba74
commit d505f481a4
2 changed files with 16 additions and 2 deletions

View File

@ -37,7 +37,7 @@ import org.eclipse.jetty.websocket.client.WebSocketClient;
*/
public class SimpleEchoClient
{
@WebSocket
@WebSocket(maxMessageSize = 64 * 1024)
public static class SimpleEchoSocket
{
private final CountDownLatch closeLatch;
@ -107,7 +107,7 @@ public class SimpleEchoClient
URI echoUri = new URI(destUri);
ClientUpgradeRequest request = new ClientUpgradeRequest();
request.addExtensions("x-webkit-deflate-frame");
// request.addExtensions("x-webkit-deflate-frame");
client.connect(socket,echoUri,request);
System.out.printf("Connecting to : %s%n",echoUri);

View File

@ -123,6 +123,11 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private static final Logger LOG = Log.getLogger(AbstractWebSocketConnection.class);
/**
* Minimum size of a buffer is the determined to be what would be the maximum framing header size (not including payload)
*/
private static final int MIN_BUFFER_SIZE = Generator.OVERHEAD;
private final ForkInvoker<Callback> invoker = new FlushInvoker();
private final ByteBufferPool bufferPool;
private final Scheduler scheduler;
@ -501,6 +506,15 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
this.extensions = extensions;
}
@Override
public void setInputBufferSize(int inputBufferSize)
{
if(inputBufferSize < MIN_BUFFER_SIZE) {
throw new IllegalArgumentException("Cannot have buffer size less than " + MIN_BUFFER_SIZE);
}
super.setInputBufferSize(inputBufferSize);
}
@Override
public void setSession(WebSocketSession session)
{