diff src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 1034:563458c4dc93

remove HttpGenerator.reset()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 21:02:59 -0600
parents 4ada7a8c128a
children 898774c2cd87
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Thu Nov 03 04:00:25 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Thu Nov 03 21:02:59 2016 -0600
@@ -98,7 +98,7 @@
 	public volatile Request _request;
 	private volatile ServletInputStream _in;
 
-	protected final HttpGenerator _generator;
+	protected volatile HttpGenerator _generator;
 	final HttpFields _responseFields = new HttpFields();
 	protected volatile Response _response;
 	private volatile Output _out;
@@ -119,7 +119,6 @@
 	{
 		super(endpoint);
 		_connector = connector;
-		_generator = new HttpGenerator(_connector.getResponseBuffers(), endpoint);
 		_server = connector.server;
 		init();
 	}
@@ -129,8 +128,15 @@
 		_parser = new HttpParser(buffers.getHeader(), buffers.getBuffer(), _endp, new RequestHandler());
 	}
 
+	void initGenerator() {
+		if( _generator != null )
+			_generator.shutdown();
+		_generator = new HttpGenerator(_connector.getResponseBuffers(), _endp);
+	}
+
 	private void init() {
 		initParser();
+		initGenerator();
 		_request = new Request(this);
 		_response = new Response(this);
 	}
@@ -231,7 +237,6 @@
 	protected void reset()
 	{
 		_requestFields.clear();
-		_generator.reset();
 		_generator.returnBuffers();// TODO maybe only on unhandle
 		_responseFields.clear();
 		_uri.clear();
@@ -380,7 +385,7 @@
 				LOG.warn("header full: " + e);
 
 				_response.reset();
-				_generator.reset();
+				initGenerator();
 				_generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
 				_generator.completeHeader(_responseFields,HttpGenerator.LAST);
 				_generator.complete();
@@ -407,7 +412,7 @@
 				LOG.debug("",e);
 
 				_response.reset();
-				_generator.reset();
+				initGenerator();
 				_generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
 				_generator.completeHeader(_responseFields,HttpGenerator.LAST);
 				_generator.complete();