Issue #6566 - cleanups of ByteBufferCallbackAccumulator

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-08-27 11:49:18 +10:00
parent 83f2265653
commit 1dce9df48d
3 changed files with 8 additions and 12 deletions

View File

@ -15,7 +15,6 @@ package org.eclipse.jetty.io;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jetty.util.BufferUtil;
@ -74,19 +73,16 @@ public class ByteBufferCallbackAccumulator
public void writeTo(ByteBuffer buffer)
{
for (Iterator<Entry> iterator = _entries.iterator(); iterator.hasNext();)
if (BufferUtil.space(buffer) < _length)
throw new IllegalArgumentException("not enough buffer space remaining");
for (Entry entry : _entries)
{
Entry entry = iterator.next();
_length -= entry.buffer.remaining();
buffer.put(entry.buffer);
iterator.remove();
entry.callback.succeeded();
}
if (!_entries.isEmpty())
throw new IllegalStateException("remaining entries: " + _entries.size());
if (_length != 0)
throw new IllegalStateException("non-zero length: " + _length);
_entries.clear();
_length = 0;
}
public void fail(Throwable t)

View File

@ -156,8 +156,8 @@ public abstract class DispatchedMessageSink extends AbstractMessageSink
@Override
public void succeeded()
{
session.demand(1);
super.succeeded();
session.demand(1);
}
};
}

View File

@ -326,7 +326,7 @@ public class JettyWebSocketFrameHandler implements FrameHandler
if (activeMessageSink == null)
{
callback.succeeded();
coreSession.demand(1);
demand();
return;
}