415314 Jetty should not commit response on output if < Response.setBufferSize() bytes are written
This commit is contained in:
parent
c0402dec4a
commit
ad8db51ed5
|
@ -57,6 +57,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
||||||
private long _written;
|
private long _written;
|
||||||
private ByteBuffer _aggregate;
|
private ByteBuffer _aggregate;
|
||||||
private int _bufferSize;
|
private int _bufferSize;
|
||||||
|
private int _commitSize;
|
||||||
private WriteListener _writeListener;
|
private WriteListener _writeListener;
|
||||||
private volatile Throwable _onError;
|
private volatile Throwable _onError;
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ write completed - - - ASYNC READY->owp
|
||||||
{
|
{
|
||||||
_channel = channel;
|
_channel = channel;
|
||||||
_bufferSize = _channel.getHttpConfiguration().getOutputBufferSize();
|
_bufferSize = _channel.getHttpConfiguration().getOutputBufferSize();
|
||||||
|
_commitSize=_bufferSize/4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWritten()
|
public boolean isWritten()
|
||||||
|
@ -231,7 +233,7 @@ write completed - - - ASYNC READY->owp
|
||||||
|
|
||||||
// Should we aggregate?
|
// Should we aggregate?
|
||||||
int capacity = getBufferSize();
|
int capacity = getBufferSize();
|
||||||
if (!complete && len<=capacity/4)
|
if (!complete && len<=_commitSize)
|
||||||
{
|
{
|
||||||
if (_aggregate == null)
|
if (_aggregate == null)
|
||||||
_aggregate = _channel.getByteBufferPool().acquire(capacity, false);
|
_aggregate = _channel.getByteBufferPool().acquire(capacity, false);
|
||||||
|
@ -271,7 +273,7 @@ write completed - - - ASYNC READY->owp
|
||||||
|
|
||||||
// Should we aggregate?
|
// Should we aggregate?
|
||||||
int capacity = getBufferSize();
|
int capacity = getBufferSize();
|
||||||
if (!complete && len<=capacity/4)
|
if (!complete && len<=_commitSize)
|
||||||
{
|
{
|
||||||
if (_aggregate == null)
|
if (_aggregate == null)
|
||||||
_aggregate = _channel.getByteBufferPool().acquire(capacity, false);
|
_aggregate = _channel.getByteBufferPool().acquire(capacity, false);
|
||||||
|
@ -294,7 +296,7 @@ write completed - - - ASYNC READY->owp
|
||||||
_channel.write(_aggregate, complete && len==0);
|
_channel.write(_aggregate, complete && len==0);
|
||||||
|
|
||||||
// should we fill aggregate again from the buffer?
|
// should we fill aggregate again from the buffer?
|
||||||
if (len>0 && !complete && len<=_aggregate.capacity()/4)
|
if (len>0 && !complete && len<=_commitSize)
|
||||||
{
|
{
|
||||||
BufferUtil.append(_aggregate, b, off, len);
|
BufferUtil.append(_aggregate, b, off, len);
|
||||||
return;
|
return;
|
||||||
|
@ -596,7 +598,8 @@ write completed - - - ASYNC READY->owp
|
||||||
|
|
||||||
public void setBufferSize(int size)
|
public void setBufferSize(int size)
|
||||||
{
|
{
|
||||||
this._bufferSize = size;
|
_bufferSize = size;
|
||||||
|
_commitSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetBuffer()
|
public void resetBuffer()
|
||||||
|
@ -704,12 +707,10 @@ write completed - - - ASYNC READY->owp
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO write comments
|
if (!_complete && _len<BufferUtil.space(_aggregate) && _len<_commitSize)
|
||||||
if (!_complete && _len<BufferUtil.space(_aggregate) && _len<_aggregate.capacity()/4)
|
|
||||||
{
|
{
|
||||||
BufferUtil.put(_buffer,_aggregate);
|
BufferUtil.put(_buffer,_aggregate);
|
||||||
}
|
}
|
||||||
// TODO write comments
|
|
||||||
else if (_len>0 && !_flushed)
|
else if (_len>0 && !_flushed)
|
||||||
{
|
{
|
||||||
_flushed=true;
|
_flushed=true;
|
||||||
|
|
Loading…
Reference in New Issue