changeset 918:7b62446899c6

remove unused states in AsyncContinuation
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 03:37:53 -0600
parents 1fc8ee20cb18
children dd6b1f079634
files src/org/eclipse/jetty/server/AsyncContinuation.java
diffstat 1 files changed, 3 insertions(+), 186 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 03:23:55 2016 -0600
+++ b/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 03:37:53 2016 -0600
@@ -71,12 +71,6 @@
 	// COMPLETED
 	private static final int __IDLE=0;         // Idle request
 	private static final int __DISPATCHED=1;   // Request dispatched to filter/servlet
-	private static final int __ASYNCSTARTED=2; // Suspend called, but not yet returned to container
-	private static final int __REDISPATCHING=3;// resumed while dispatched
-	private static final int __ASYNCWAIT=4;    // Suspended and parked
-	private static final int __REDISPATCH=5;   // Has been scheduled
-	private static final int __REDISPATCHED=6; // Request redispatched to filter/servlet
-	private static final int __COMPLETING=7;   // complete while dispatched
 	private static final int __UNCOMPLETED=8;  // Request is completable
 	private static final int __COMPLETED=9;    // Request is complete
 	
@@ -215,12 +209,6 @@
 		{
 			switch(_state)
 			{
-				case __ASYNCSTARTED:
-				case __REDISPATCHING:
-				case __COMPLETING:
-				case __ASYNCWAIT:
-					return true;
-					
 				default:
 					return false;   
 			}
@@ -234,10 +222,6 @@
 		{
 			switch(_state)
 			{
-				case __ASYNCSTARTED:
-				case __ASYNCWAIT:
-					return true;
-					
 				default:
 					return false;   
 			}
@@ -251,12 +235,6 @@
 		{
 			switch(_state)
 			{
-				case __REDISPATCH:
-				case __REDISPATCHED:
-				case __REDISPATCHING:
-				case __COMPLETING:
-					return true;
-					
 				default:
 					return false;   
 			}
@@ -281,12 +259,6 @@
 			return
 			((_state==__IDLE)?"IDLE":
 				(_state==__DISPATCHED)?"DISPATCHED":
-					(_state==__ASYNCSTARTED)?"ASYNCSTARTED":
-						(_state==__ASYNCWAIT)?"ASYNCWAIT":
-							(_state==__REDISPATCHING)?"REDISPATCHING":
-								(_state==__REDISPATCH)?"REDISPATCH":
-									(_state==__REDISPATCHED)?"REDISPATCHED":
-										(_state==__COMPLETING)?"COMPLETING":
 											(_state==__UNCOMPLETED)?"UNCOMPLETED":
 												(_state==__COMPLETED)?"COMPLETE":
 													("UNKNOWN?"+_state))+
@@ -322,17 +294,6 @@
 					}
 					return true;
 					
-				case __COMPLETING:
-					_state=__UNCOMPLETED;
-					return false;
-
-				case __ASYNCWAIT:
-					return false;
-					
-				case __REDISPATCH:
-					_state=__REDISPATCHED;
-					return true;
-
 				default:
 					throw new IllegalStateException(this.getStatusString());
 			}
@@ -353,39 +314,13 @@
 		{
 			switch(_state)
 			{
-				case __REDISPATCHED:
 				case __DISPATCHED:
-					_state=__UNCOMPLETED;
+					_state = __UNCOMPLETED;
 					return true;
 
 				case __IDLE:
 					throw new IllegalStateException(this.getStatusString());
 
-				case __ASYNCSTARTED:
-					_initial=false;
-					_state=__ASYNCWAIT;
-					scheduleTimeout(); // could block and change state.
-					if (_state==__ASYNCWAIT)
-						return true;
-					else if (_state==__COMPLETING)
-					{
-						_state=__UNCOMPLETED;
-						return true;
-					}         
-					_initial=false;
-					_state=__REDISPATCHED;
-					return false; 
-
-				case __REDISPATCHING:
-					_initial=false;
-					_state=__REDISPATCHED;
-					return false; 
-
-				case __COMPLETING:
-					_initial=false;
-					_state=__UNCOMPLETED;
-					return true;
-
 				default:
 					throw new IllegalStateException(this.getStatusString());
 			}
@@ -400,101 +335,15 @@
 		{
 			switch(_state)
 			{
-				case __ASYNCSTARTED:
-					_state=__REDISPATCHING;
-					_resumed=true;
-					return;
-
-				case __ASYNCWAIT:
-					dispatch=!_expired;
-					_state=__REDISPATCH;
-					_resumed=true;
-					break;
-					
-				case __REDISPATCH:
-					return;
-					
 				default:
 					throw new IllegalStateException(this.getStatusString());
 			}
 		}
-		
-		if (dispatch)
-		{
-			cancelTimeout();
-			scheduleDispatch();
-		}
 	}
 
 	/* ------------------------------------------------------------ */
 	protected void expired()
 	{
-		final List<ContinuationListener> cListeners;
-		final List<AsyncListener> aListeners;
-		synchronized (this)
-		{
-			switch(_state)
-			{
-				case __ASYNCSTARTED:
-				case __ASYNCWAIT:
-					cListeners=_continuationListeners;
-					aListeners=_asyncListeners;
-					break;
-				default:
-					cListeners=null;
-					aListeners=null;
-					return;
-			}
-			_expired=true;
-		}
-		
-		if (aListeners!=null)
-		{
-			for (AsyncListener listener : aListeners)
-			{
-				try
-				{
-					listener.onTimeout(_event);
-				}
-				catch(Exception e)
-				{
-					LOG.debug("",e);
-					_connection.getRequest().setAttribute(RequestDispatcher.ERROR_EXCEPTION,e);
-					break;
-				}
-			}
-		}
-		if (cListeners!=null)
-		{
-			for (ContinuationListener listener : cListeners)
-			{
-				try
-				{
-					listener.onTimeout(this);
-				}
-				catch(Exception e)
-				{
-					LOG.warn("",e);
-				}
-			}
-		}
-		
-		synchronized (this)
-		{
-			switch(_state)
-			{
-				case __ASYNCSTARTED:
-				case __ASYNCWAIT:
-					dispatch();
-					break;
-					
-				default:
-					if (!_continuation)
-						_expired=false;
-			}
-		}
-
-		scheduleDispatch();
 	}
 	
 	/* ------------------------------------------------------------ */
@@ -510,28 +359,12 @@
 			switch(_state)
 			{
 				case __DISPATCHED:
-				case __REDISPATCHED:
 					throw new IllegalStateException(this.getStatusString());
 
-				case __ASYNCSTARTED:
-					_state=__COMPLETING;
-					return;
-					
-				case __ASYNCWAIT:
-					_state=__COMPLETING;
-					dispatch=!_expired;
-					break;
-					
 				default:
 					throw new IllegalStateException(this.getStatusString());
 			}
 		}
-		
-		if (dispatch)
-		{
-			cancelTimeout();
-			scheduleDispatch();
-		}
 	}
 	
 	/* ------------------------------------------------------------ */
@@ -545,15 +378,6 @@
 		{
 			switch(_state)
 			{
-				case __REDISPATCHING:
-				case __ASYNCSTARTED:
-					_state=__COMPLETING;
-					_resumed=false;
-					return;
-					
-				case __COMPLETING:
-					return;
-					
 				default:
 					throw new IllegalStateException(this.getStatusString());
 			}
@@ -589,7 +413,7 @@
 			switch(_state)
 			{
 				case __UNCOMPLETED:
-					_state=__COMPLETED;
+					_state = __COMPLETED;
 					cListeners=_continuationListeners;
 					aListeners=_asyncListeners;
 					break;
@@ -646,7 +470,6 @@
 			switch(_state)
 			{
 				case __DISPATCHED:
-				case __REDISPATCHED:
 					throw new IllegalStateException(getStatusString());
 				default:
 					_state=__IDLE;
@@ -746,7 +569,7 @@
 	{
 		synchronized (this)
 		{
-			return _state==__COMPLETING;
+			return false;
 		}
 	}
 	
@@ -776,12 +599,6 @@
 		{
 			switch(_state)
 			{
-				case __ASYNCSTARTED:
-				case __REDISPATCHING:
-				case __REDISPATCH:
-				case __ASYNCWAIT:
-					return true;
-
 				default:
 					return false;
 			}