changeset 920:3268ddf919d4

remove AsyncContinuation.isAsyncStarted()
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 03:51:31 -0600
parents dd6b1f079634
children a5af9ee7cf91
files src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/AsyncContinuation.java src/org/eclipse/jetty/server/AsyncHttpConnection.java src/org/eclipse/jetty/server/Request.java src/org/eclipse/jetty/server/handler/IdleTimeoutHandler.java
diffstat 5 files changed, 63 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
diff -r dd6b1f079634 -r 3268ddf919d4 src/org/eclipse/jetty/server/AbstractHttpConnection.java
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 09 03:45:31 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 09 03:51:31 2016 -0600
@@ -514,10 +514,6 @@
 				}
 				finally
 				{
-					// Complete async requests 
-					if (error && _request.isAsyncStarted())
-						_request.getAsyncContinuation().errorComplete();
-						
 					was_continuation=_request._async.isContinuation();
 					handling = !_request._async.unhandle() && server.isRunning() && _server!=null;
 				}
diff -r dd6b1f079634 -r 3268ddf919d4 src/org/eclipse/jetty/server/AsyncContinuation.java
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 03:45:31 2016 -0600
+++ b/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 03:51:31 2016 -0600
@@ -557,15 +557,6 @@
 	}
 
 	/* ------------------------------------------------------------ */
-	public boolean isCompleting()
-	{
-		synchronized (this)
-		{
-			return false;
-		}
-	}
-	
-	/* ------------------------------------------------------------ */
 	boolean isUncompleted()
 	{
 		synchronized (this)
@@ -585,20 +576,6 @@
 
 
 	/* ------------------------------------------------------------ */
-	public boolean isAsyncStarted()
-	{
-		synchronized (this)
-		{
-			switch(_state)
-			{
-				default:
-					return false;
-			}
-		}
-	}
-
-
-	/* ------------------------------------------------------------ */
 	public boolean isAsync()
 	{
 		synchronized (this)
diff -r dd6b1f079634 -r 3268ddf919d4 src/org/eclipse/jetty/server/AsyncHttpConnection.java
--- a/src/org/eclipse/jetty/server/AsyncHttpConnection.java	Sun Oct 09 03:45:31 2016 -0600
+++ b/src/org/eclipse/jetty/server/AsyncHttpConnection.java	Sun Oct 09 03:51:31 2016 -0600
@@ -83,7 +83,7 @@
                         progress=true;
 
                     // Generate more output
-                    if (_generator.isCommitted() && !_generator.isComplete() && !_endp.isOutputShutdown() && !_request.getAsyncContinuation().isAsyncStarted())
+                    if (_generator.isCommitted() && !_generator.isComplete() && !_endp.isOutputShutdown())
                         if (_generator.flushBuffer()>0)
                             progress=true;
 
@@ -145,14 +145,6 @@
                             LOG.debug("Disabled read interest while writing response {}", _endp);
                         }
                     }
-
-                    if (!complete && _request.getAsyncContinuation().isAsyncStarted())
-                    {
-                        // The request is suspended, so even though progress has been made,
-                        // exit the while loop by setting progress to false
-                        LOG.debug("suspended {}",this);
-                        progress=false;
-                    }
                 }
             }
         }
@@ -160,16 +152,12 @@
         {
             setCurrentConnection(null);
 
-            // If we are not suspended
-            if (!_request.getAsyncContinuation().isAsyncStarted())
-            {
-                // return buffers
-                _parser.returnBuffers();
-                _generator.returnBuffers();
+            // return buffers
+            _parser.returnBuffers();
+            _generator.returnBuffers();
 
-                // reenable idle checking unless request is suspended
-                _asyncEndp.setCheckForIdle(true);
-            }
+            // reenable idle checking unless request is suspended
+            _asyncEndp.setCheckForIdle(true);
 
             // Safety net to catch spinning
             if (some_progress)
diff -r dd6b1f079634 -r 3268ddf919d4 src/org/eclipse/jetty/server/Request.java
--- a/src/org/eclipse/jetty/server/Request.java	Sun Oct 09 03:45:31 2016 -0600
+++ b/src/org/eclipse/jetty/server/Request.java	Sun Oct 09 03:51:31 2016 -0600
@@ -370,9 +370,7 @@
 	/* ------------------------------------------------------------ */
 	public AsyncContext getAsyncContext()
 	{
-		if (_async.isInitial() && !_async.isAsyncStarted())
-			throw new IllegalStateException(_async.getStatusString());
-		return _async;
+		throw new UnsupportedOperationException();
 	}
 
 	/* ------------------------------------------------------------ */
@@ -1220,7 +1218,7 @@
 
 	public boolean isAsyncStarted()
 	{
-	   return _async.isAsyncStarted();
+	   return false;
 	}
 
 
diff -r dd6b1f079634 -r 3268ddf919d4 src/org/eclipse/jetty/server/handler/IdleTimeoutHandler.java
--- a/src/org/eclipse/jetty/server/handler/IdleTimeoutHandler.java	Sun Oct 09 03:45:31 2016 -0600
+++ b/src/org/eclipse/jetty/server/handler/IdleTimeoutHandler.java	Sun Oct 09 03:51:31 2016 -0600
@@ -46,93 +46,63 @@
  */
 public class IdleTimeoutHandler extends HandlerWrapper
 {
-    private int _idleTimeoutMs = 1000;
-    private boolean _applyToAsync = false;
-    
-    
-    public boolean isApplyToAsync()
-    {
-        return _applyToAsync;
-    }
+	private int _idleTimeoutMs = 1000;
+	private boolean _applyToAsync = false;
+	
+	
+	public boolean isApplyToAsync()
+	{
+		return _applyToAsync;
+	}
 
-    /**
-     * Should the adjusted idle time be maintained for asynchronous requests
-     * @param applyToAsync true if alternate idle timeout is applied to asynchronous requests
-     */
-    public void setApplyToAsync(boolean applyToAsync)
-    {
-        _applyToAsync = applyToAsync;
-    }
+	/**
+	 * Should the adjusted idle time be maintained for asynchronous requests
+	 * @param applyToAsync true if alternate idle timeout is applied to asynchronous requests
+	 */
+	public void setApplyToAsync(boolean applyToAsync)
+	{
+		_applyToAsync = applyToAsync;
+	}
 
-    public long getIdleTimeoutMs()
-    {
-        return _idleTimeoutMs;
-    }
+	public long getIdleTimeoutMs()
+	{
+		return _idleTimeoutMs;
+	}
 
-    /**
-     * @param idleTimeoutMs The idle timeout in MS to apply while dispatched or async
-     */
-    public void setIdleTimeoutMs(int _idleTimeoutMs)
-    {
-        this._idleTimeoutMs = _idleTimeoutMs;
-    }
-    
+	/**
+	 * @param idleTimeoutMs The idle timeout in MS to apply while dispatched or async
+	 */
+	public void setIdleTimeoutMs(int _idleTimeoutMs)
+	{
+		this._idleTimeoutMs = _idleTimeoutMs;
+	}
+	
    
-    @Override
-    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
-    {
-        AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
-        final EndPoint endp = connection==null?null:connection.getEndPoint();
-        
-        final int idle_timeout;
-        if (endp==null)
-            idle_timeout=-1;
-        else
-        {
-            idle_timeout=endp.getMaxIdleTime();
-            endp.setMaxIdleTime(_idleTimeoutMs);
-        }
-        
-        try
-        {
-            super.handle(target,baseRequest,request,response);
-        }
-        finally
-        {
-            if (endp!=null)
-            {
-                if (_applyToAsync && request.isAsyncStarted())
-                {
-                    request.getAsyncContext().addListener(new AsyncListener()
-                    {
-                        @Override
-                        public void onTimeout(AsyncEvent event) throws IOException
-                        {                            
-                        }
-                        
-                        @Override
-                        public void onStartAsync(AsyncEvent event) throws IOException
-                        {
-                        }
-                        
-                        @Override
-                        public void onError(AsyncEvent event) throws IOException
-                        {
-                            endp.setMaxIdleTime(idle_timeout);
-                        }
-                        
-                        @Override
-                        public void onComplete(AsyncEvent event) throws IOException
-                        {
-                            endp.setMaxIdleTime(idle_timeout);
-                        }
-                    });
-                }
-                else 
-                {
-                    endp.setMaxIdleTime(idle_timeout);
-                }
-            }
-        }
-    }
+	@Override
+	public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+	{
+		AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
+		final EndPoint endp = connection==null?null:connection.getEndPoint();
+		
+		final int idle_timeout;
+		if (endp==null)
+			idle_timeout=-1;
+		else
+		{
+			idle_timeout=endp.getMaxIdleTime();
+			endp.setMaxIdleTime(_idleTimeoutMs);
+		}
+		
+		try
+		{
+			super.handle(target,baseRequest,request,response);
+		}
+		finally
+		{
+			if (endp!=null)
+			{
+				endp.setMaxIdleTime(idle_timeout);
+			}
+		}
+	}
 }