diff src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 939:8db5996c8c89

remove AsyncContinuation
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Oct 2016 00:50:06 -0600
parents fe461f7cfc8e
children 1094975d013b
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 09 23:48:32 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Mon Oct 10 00:50:06 2016 -0600
@@ -390,22 +390,12 @@
 		_earlyEOF = false;
 	}
 
-	/* ------------------------------------------------------------ */
 	protected void handleRequest() throws IOException
 	{
 		boolean error = false;
 
-		String threadName=null;
-		Throwable async_exception=null;
 		try
 		{
-			if (LOG.isDebugEnabled())
-			{
-				threadName=Thread.currentThread().getName();
-				Thread.currentThread().setName(threadName+" - "+_uri);
-			}
-
-
 			// Loop here to handle async request redispatches.
 			// The loop is controlled by the call to async.unhandle in the
 			// finally block below.  If call is from a non-blocking connector,
@@ -414,134 +404,113 @@
 			// the wait for the asynchronous dispatch or timeout actually happens
 			// within the call to unhandle().
 
-			final Server server=_server;
-			_request._async.handling();
-			if(server!=null && server.isRunning())
+			_request.setHandled(false);
+
+			String info=null;
+			try
 			{
-				_request.setHandled(false);
+				_uri.getPort();
+				String path = null;
 
-				String info=null;
 				try
 				{
-					_uri.getPort();
-					String path = null;
+					path = _uri.getDecodedPath();
+				}
+				catch (Exception e)
+				{
+					LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1");
+					LOG.trace("",e);
+					path = _uri.getDecodedPath(StringUtil.__ISO_8859_1);
+				}
 
-					try
-					{
-						path = _uri.getDecodedPath();
-					}
-					catch (Exception e)
-					{
-						LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1");
-						LOG.trace("",e);
-						path = _uri.getDecodedPath(StringUtil.__ISO_8859_1);
-					}
-
-					info=URIUtil.canonicalPath(path);
-					if (info==null && !_request.getMethod().equals(HttpMethods.CONNECT))
+				info = URIUtil.canonicalPath(path);
+				if (info==null && !_request.getMethod().equals(HttpMethods.CONNECT))
+				{
+					if (path==null && _uri.getScheme()!=null && _uri.getHost()!=null)
 					{
-						if (path==null && _uri.getScheme()!=null && _uri.getHost()!=null)
-						{
-							info="/";
-							_request.setRequestURI("");
-						}
-						else
-							throw new HttpException(400);
+						info="/";
+						_request.setRequestURI("");
 					}
-					_request.setPathInfo(info);
-
-					if (_out!=null)
-						_out.reopen();
-
-					_request.setDispatcherType(DispatcherType.REQUEST);
-					_connector.customize(_endp, _request);
-					server.handle(this);
+					else
+						throw new HttpException(400);
 				}
-				catch (EofException e)
-				{
-					async_exception=e;
-					LOG.debug("",e);
-					error=true;
-					_request.setHandled(true);
-					if (!_response.isCommitted())
-						_generator.sendError(500, null, null, true);
-				}
-				catch (RuntimeIOException e)
-				{
-					async_exception=e;
-					LOG.debug("",e);
-					error=true;
-					_request.setHandled(true);
-				}
-				catch (HttpException e)
-				{
-					LOG.debug("",e);
-					error=true;
-					_request.setHandled(true);
-					_response.sendError(e.getStatus(), e.getReason());
-				}
-				catch (Throwable e)
-				{
-					async_exception=e;
-					LOG.warn(String.valueOf(_uri),e);
-					error=true;
-					_request.setHandled(true);
-					_generator.sendError(info==null?400:500, null, null, true);
-					
-				}
-				finally
-				{
-					_request._async.unhandle();
-				}
+				_request.setPathInfo(info);
+
+				if (_out!=null)
+					_out.reopen();
+
+				_request.setDispatcherType(DispatcherType.REQUEST);
+				_connector.customize(_endp, _request);
+				_server.handle(this);
+			}
+			catch (EofException e)
+			{
+				LOG.debug("",e);
+				error=true;
+				_request.setHandled(true);
+				if (!_response.isCommitted())
+					_generator.sendError(500, null, null, true);
+			}
+			catch (RuntimeIOException e)
+			{
+				LOG.debug("",e);
+				error=true;
+				_request.setHandled(true);
+			}
+			catch (HttpException e)
+			{
+				LOG.debug("",e);
+				error=true;
+				_request.setHandled(true);
+				_response.sendError(e.getStatus(), e.getReason());
+			}
+			catch (Throwable e)
+			{
+				LOG.warn(String.valueOf(_uri),e);
+				error=true;
+				_request.setHandled(true);
+				_generator.sendError(info==null?400:500, null, null, true);
+				
 			}
 		}
 		finally
 		{
-			if (threadName!=null)
-				Thread.currentThread().setName(threadName);
-
-			if (_request._async.isUncompleted())
+			if (_expect100Continue)
 			{
-				
-				_request._async.doComplete(async_exception);
+				LOG.debug("100 continues not sent");
+				// We didn't send 100 continues, but the latest interpretation
+				// of the spec (see httpbis) is that the client will either
+				// send the body anyway, or close.  So we no longer need to
+				// do anything special here other than make the connection not persistent
+				_expect100Continue = false;
+				if (!_response.isCommitted())
+					_generator.setPersistent(false);
+			}
 
-				if (_expect100Continue)
+			if(_endp.isOpen())
+			{
+				if (error)
 				{
-					LOG.debug("100 continues not sent");
-					// We didn't send 100 continues, but the latest interpretation
-					// of the spec (see httpbis) is that the client will either
-					// send the body anyway, or close.  So we no longer need to
-					// do anything special here other than make the connection not persistent
-					_expect100Continue = false;
-					if (!_response.isCommitted())
-						_generator.setPersistent(false);
-				}
-
-				if(_endp.isOpen())
-				{
-					if (error)
-					{
-						_endp.shutdownOutput();
-						_generator.setPersistent(false);
-						if (!_generator.isComplete())
-							_response.complete();
-					}
-					else
-					{
-						if (!_response.isCommitted() && !_request.isHandled())
-							_response.sendError(HttpServletResponse.SC_NOT_FOUND);
+					_endp.shutdownOutput();
+					_generator.setPersistent(false);
+					if (!_generator.isComplete())
 						_response.complete();
-						if (_generator.isPersistent())
-							_connector.persist(_endp);
-					}
 				}
 				else
 				{
+					if (!_response.isCommitted() && !_request.isHandled())
+						_response.sendError(HttpServletResponse.SC_NOT_FOUND);
 					_response.complete();
+					if (_generator.isPersistent())
+						_connector.persist(_endp);
 				}
+			}
+			else
+			{
+				_response.complete();
+			}
 
-				_request.setHandled(true);
-			}
+			_request.setHandled(true);
 		}
 	}