free generator buffers

This commit is contained in:
Greg Wilkins 2011-08-29 12:26:48 +10:00
parent cd5c73366e
commit 2a5a3a4d01
2 changed files with 19 additions and 1 deletions

View File

@ -114,7 +114,7 @@ public abstract class AbstractGenerator implements Generator
_contentLength = HttpTokens.UNKNOWN_CONTENT;
_date = null;
// always return the buffer
// always return the body buffer
if (_buffer!=null)
_buffers.returnBuffer(_buffer);
_buffer=null;
@ -132,6 +132,22 @@ public abstract class AbstractGenerator implements Generator
_method=null;
}
/* ------------------------------------------------------------------------------- */
public void returnBuffers()
{
if (_buffer!=null && _buffer.length()==0)
{
_buffers.returnBuffer(_buffer);
_buffer=null;
}
if (_header!=null && _header.length()==0)
{
_buffers.returnBuffer(_header);
_header=null;
}
}
/* ------------------------------------------------------------------------------- */
public void resetBuffer()
{

View File

@ -73,6 +73,8 @@ public interface Generator
void reset(boolean returnBuffers);
void resetBuffer();
void returnBuffers();
void sendError(int code, String reason, String content, boolean close) throws IOException;