Mercurial Hosting > luan
changeset 934:fe461f7cfc8e
simplify AsyncContinuation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 21:03:00 -0600 |
parents | c9513d80f305 |
children | aa7dc1802d29 |
files | src/org/eclipse/jetty/continuation/Continuation.java 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/BlockingHttpConnection.java |
diffstat | 5 files changed, 14 insertions(+), 181 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/continuation/Continuation.java Sun Oct 09 20:25:02 2016 -0600 +++ b/src/org/eclipse/jetty/continuation/Continuation.java Sun Oct 09 21:03:00 2016 -0600 @@ -155,7 +155,7 @@ * continuation after a call to {@link #suspend()} or {@link #suspend(ServletResponse)}. * A timeout of <=0 means the continuation will never expire. */ - void setTimeout(long timeoutMs); +// void setTimeout(long timeoutMs); /* ------------------------------------------------------------ */ /** @@ -305,7 +305,7 @@ * if the request is not suspended. * */ - void complete(); +// void complete(); /* ------------------------------------------------------------ */ /** @@ -313,7 +313,7 @@ * request has been redispatched due to being resumed, completed or * timed out. */ - boolean isSuspended(); +// boolean isSuspended(); /* ------------------------------------------------------------ */ /** @@ -352,7 +352,7 @@ * @return True if {@link #suspend(ServletResponse)} has been passed a * {@link ServletResponseWrapper} instance. */ - boolean isResponseWrapped(); +// boolean isResponseWrapped(); /* ------------------------------------------------------------ */
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Sun Oct 09 20:25:02 2016 -0600 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Sun Oct 09 21:03:00 2016 -0600 @@ -658,7 +658,7 @@ */ public boolean isSuspended() { - return _request.getAsyncContinuation().isSuspended(); + return false; } /* ------------------------------------------------------------ */
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java Sun Oct 09 20:25:02 2016 -0600 +++ b/src/org/eclipse/jetty/server/AsyncContinuation.java Sun Oct 09 21:03:00 2016 -0600 @@ -39,7 +39,6 @@ import org.eclipse.jetty.util.URIUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.eclipse.jetty.util.thread.Timeout; /* ------------------------------------------------------------ */ /** Implementation of Continuation interfaces @@ -76,23 +75,16 @@ /* ------------------------------------------------------------ */ private int _state; - private volatile boolean _responseWrapped; - private long _timeoutMs=DEFAULT_TIMEOUT; private volatile long _expireAt; - /* ------------------------------------------------------------ */ protected AsyncContinuation() { _state=__IDLE; } - /* ------------------------------------------------------------ */ - protected void setConnection(final AbstractHttpConnection connection) + protected synchronized void setConnection(final AbstractHttpConnection connection) { - synchronized(this) - { - _connection=connection; - } + _connection=connection; } /* ------------------------------------------------------------ */ @@ -129,81 +121,8 @@ } } - /* ------------------------------------------------------------ */ - public void setTimeout(long ms) - { - synchronized(this) - { - _timeoutMs=ms; - } - } - /* ------------------------------------------------------------ */ - public long getTimeout() - { - synchronized(this) - { - return _timeoutMs; - } - } - - /* ------------------------------------------------------------ */ - /** - * @see org.eclipse.jetty.continuation.Continuation#keepWrappers() - */ - - /* ------------------------------------------------------------ */ - /** - * @see org.eclipse.jetty.continuation.Continuation#isResponseWrapped() - */ - public boolean isResponseWrapped() - { - return _responseWrapped; - } - - /* ------------------------------------------------------------ */ - /* (non-Javadoc) - * @see javax.servlet.ServletRequest#isSuspended() - */ - public boolean isSuspended() - { - synchronized(this) - { - switch(_state) - { - default: - return false; - } - } - } - /* ------------------------------------------------------------ */ - public boolean isSuspending() - { - synchronized(this) - { - switch(_state) - { - default: - return false; - } - } - } - - /* ------------------------------------------------------------ */ - public boolean isDispatchable() - { - synchronized(this) - { - switch(_state) - { - default: - return false; - } - } - } - - /* ------------------------------------------------------------ */ @Override public String toString() { @@ -213,7 +132,6 @@ } } - /* ------------------------------------------------------------ */ public String getStatusString() { synchronized (this) @@ -263,54 +181,7 @@ } } - public void dispatch() - { - throw new UnsupportedOperationException(); - } - - /* ------------------------------------------------------------ */ - protected void expired() - { - } - - /* ------------------------------------------------------------ */ - /* (non-Javadoc) - * @see javax.servlet.ServletRequest#complete() - */ - public void complete() - { - // just like resume, except don't set _resumed=true; - boolean dispatch=false; - synchronized (this) - { - switch(_state) - { - case __DISPATCHED: - throw new IllegalStateException(this.getStatusString()); - - default: - throw new IllegalStateException(this.getStatusString()); - } - } - } - - /* ------------------------------------------------------------ */ - /* (non-Javadoc) - * @see javax.servlet.ServletRequest#complete() - */ - public void errorComplete() - { - // just like complete except can overrule a prior dispatch call; - synchronized (this) - { - switch(_state) - { - default: - throw new IllegalStateException(this.getStatusString()); - } - } - } - + /* ------------------------------------------------------------ */ /* (non-Javadoc) * @see javax.servlet.ServletRequest#complete() @@ -383,9 +254,7 @@ default: _state=__IDLE; } - _responseWrapped=false; cancelTimeout(); - _timeoutMs=DEFAULT_TIMEOUT; _continuationListeners=null; } } @@ -407,30 +276,14 @@ } } - boolean isUncompleted() + synchronized boolean isUncompleted() { - synchronized (this) - { - return _state==__UNCOMPLETED; - } + return _state==__UNCOMPLETED; } - public boolean isComplete() + public synchronized boolean isComplete() { - synchronized (this) - { - return _state==__COMPLETED; - } - } - - public void dispatch(ServletContext context, String path) - { - throw new UnsupportedOperationException(); - } - - public void dispatch(String path) - { - throw new UnsupportedOperationException(); + return _state==__COMPLETED; } /* ------------------------------------------------------------ */ @@ -451,26 +304,6 @@ return _connection.getResponse(); } - /* ------------------------------------------------------------ */ - public void start(final Runnable run) - { - } - - /* ------------------------------------------------------------ */ - public boolean hasOriginalRequestAndResponse() - { - synchronized (this) - { - return false; - } - } - - /* ------------------------------------------------------------ */ - public ContextHandler getContextHandler() - { - return null; - } - /* ------------------------------------------------------------ */ /**
--- a/src/org/eclipse/jetty/server/AsyncHttpConnection.java Sun Oct 09 20:25:02 2016 -0600 +++ b/src/org/eclipse/jetty/server/AsyncHttpConnection.java Sun Oct 09 21:03:00 2016 -0600 @@ -175,7 +175,7 @@ public void onInputShutdown() throws IOException { // If we don't have a committed response and we are not suspended - if (_generator.isIdle() && !_request.getAsyncContinuation().isSuspended()) + if (_generator.isIdle()) { // then no more can happen, so close. _endp.close();
--- a/src/org/eclipse/jetty/server/BlockingHttpConnection.java Sun Oct 09 20:25:02 2016 -0600 +++ b/src/org/eclipse/jetty/server/BlockingHttpConnection.java Sun Oct 09 21:03:00 2016 -0600 @@ -118,7 +118,7 @@ } // If we don't have a committed response and we are not suspended - if (_endp.isInputShutdown() && _generator.isIdle() && !_request.getAsyncContinuation().isSuspended()) + if (_endp.isInputShutdown() && _generator.isIdle()) { // then no more can happen, so close. _endp.close();