diff src/org/eclipse/jetty/http/HttpGenerator.java @ 1068:9d357b9e4bcb

fix BufferUtil.newBuffer()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 00:23:05 -0700
parents 56b515be91e1
children 7dd6ec499000
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpGenerator.java	Thu Nov 10 00:08:39 2016 -0700
+++ b/src/org/eclipse/jetty/http/HttpGenerator.java	Thu Nov 10 00:23:05 2016 -0700
@@ -150,7 +150,6 @@
 				if (_bufferChunked)
 				{
 					JBuffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining());
-					nc.clear();
 					nc.putQ(_content);
 					nc.putQ(HttpTokens.CRLF);
 					BufferUtil.putHexInt(nc, content.remaining());
@@ -162,7 +161,6 @@
 				else
 				{
 					JBuffer nc = _buffers.getBuffer(_content.remaining()+content.remaining());
-					nc.clear();
 					nc.putQ(_content);
 					nc.putQ(content);
 					nc.flip();
@@ -186,10 +184,6 @@
 		}
 		else if (!_bufferChunked)
 		{
-			// Yes - so we better check we have a buffer
-			if (_buffer == null)
-				_buffer = _buffers.getBuffer();
-
 			// Copy _content to buffer;
 			int len = _buffer.put(_content);
 			_content.skip(len);
@@ -926,7 +920,7 @@
 	private Boolean _persistent = null;
 
 	private final JBuffer _header; // JBuffer for HTTP header (and maybe small _content)
-	private JBuffer _buffer; // JBuffer for copy of passed _content
+	private final JBuffer _buffer; // JBuffer for copy of passed _content
 	private JBuffer _content; // JBuffer passed to addContent
 
 
@@ -935,7 +929,8 @@
 		this._buffers = buffers;
 		this._endp = io;
 		_header = _buffers.getHeader();
-		_header.clear();
+		_buffer = _buffers.getBuffer();
+		_buffer.limit(0);
 	}
 
 	public final boolean isOpen()
@@ -963,15 +958,11 @@
 	 */
 	public final int getContentBufferSize()
 	{
-		if (_buffer==null)
-			_buffer = _buffers.getBuffer();
 		return _buffer.capacity();
 	}
 
 	public final JBuffer getUncheckedBuffer()
 	{
-		if (_buffer == null)
-			_buffer = _buffers.getBuffer();
 		return _buffer;
 	}
 
@@ -1047,7 +1038,6 @@
 			if (len>1024)
 				len=1024;
 			_reason = BufferUtil.newBuffer(len);
-			_reason.clear();
 			for (int i=0;i<len;i++)
 			{
 				char ch = reason.charAt(i);