Issue #6566 - cleanups of ByteBufferCallbackAccumulator
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
83f2265653
commit
1dce9df48d
|
@ -15,7 +15,6 @@ package org.eclipse.jetty.io;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
|
@ -74,19 +73,16 @@ public class ByteBufferCallbackAccumulator
|
||||||
|
|
||||||
public void writeTo(ByteBuffer buffer)
|
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);
|
buffer.put(entry.buffer);
|
||||||
iterator.remove();
|
|
||||||
entry.callback.succeeded();
|
entry.callback.succeeded();
|
||||||
}
|
}
|
||||||
|
_entries.clear();
|
||||||
if (!_entries.isEmpty())
|
_length = 0;
|
||||||
throw new IllegalStateException("remaining entries: " + _entries.size());
|
|
||||||
if (_length != 0)
|
|
||||||
throw new IllegalStateException("non-zero length: " + _length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fail(Throwable t)
|
public void fail(Throwable t)
|
||||||
|
|
|
@ -156,8 +156,8 @@ public abstract class DispatchedMessageSink extends AbstractMessageSink
|
||||||
@Override
|
@Override
|
||||||
public void succeeded()
|
public void succeeded()
|
||||||
{
|
{
|
||||||
session.demand(1);
|
|
||||||
super.succeeded();
|
super.succeeded();
|
||||||
|
session.demand(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ public class JettyWebSocketFrameHandler implements FrameHandler
|
||||||
if (activeMessageSink == null)
|
if (activeMessageSink == null)
|
||||||
{
|
{
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
coreSession.demand(1);
|
demand();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue