ticket 664 - update continuation handling to (re)support updating timeout
This commit is contained in:
parent
c74bb062af
commit
a274c5f0b9
1 changed files with 15 additions and 8 deletions
|
|
@ -52,9 +52,10 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging
|
|||
|
||||
Some(continuation)
|
||||
}
|
||||
//
|
||||
// the timeout was reset and the continuation was resumed
|
||||
// need to update the timeout and resuspend
|
||||
// very important to clear the context so the request is not rebroadcast to the endpoint
|
||||
// this happens when used with getAsyncContinuation
|
||||
//
|
||||
case (false, false, false) => {
|
||||
|
||||
continuation.setTimeout(continuation.getAttribute(TimeoutAttribute).asInstanceOf[Long])
|
||||
|
|
@ -63,18 +64,23 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging
|
|||
|
||||
None
|
||||
}
|
||||
//
|
||||
// we don't actually expect to get this one here since the listener will finish him off
|
||||
//
|
||||
case (_, _, true) => {
|
||||
//
|
||||
// the timeout was reset and the continuation is still suspended
|
||||
// this happens when used with startAsync
|
||||
//
|
||||
case (false, true, false) => {
|
||||
|
||||
continuation.setTimeout(continuation.getAttribute(TimeoutAttribute).asInstanceOf[Long])
|
||||
continuation.removeAttribute(TimeoutAttribute)
|
||||
|
||||
None
|
||||
}
|
||||
//
|
||||
// snuh?
|
||||
// unexpected continution state(s) - log and do nothing
|
||||
//
|
||||
case _ => {
|
||||
continuation.cancel
|
||||
log.slf4j.warn("Received continuation in unexpected state: "+continuation.isInitial+" "+continuation.isSuspended+" "+continuation.isExpired+" "+continuation.isResumed)
|
||||
//continuation.cancel
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
@ -88,6 +94,7 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging
|
|||
def timeout(ms:Long):Boolean = _continuation match {
|
||||
case None => false
|
||||
case Some(continuation) =>
|
||||
log.slf4j.info("reseting timeout...")
|
||||
continuation.setAttribute(TimeoutAttribute, ms)
|
||||
continuation.resume
|
||||
true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue