Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Dpp issue 1193 #1230

Merged
merged 2 commits into from

2 participants

@dpp
Owner

Assign to @dpp

@dpp dpp was assigned
@jeppenejsum
Owner

Thanks. I've tested this on our app with several layers of ajax-generated functions and it all seems to work :-)

I'm wondering if it's possible to unit test some of this stuff. It seems quite hairy and not always immediately obvious what the issue is or what the semantics are.

@dpp dpp merged commit bcce12b into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 web/webkit/src/main/scala/net/liftweb/http/CometActor.scala
@@ -540,7 +540,7 @@ trait CometActor extends LiftActor with LiftCometActor with BindHelpers {
private def lastRendering: RenderOut =
if (dontCacheRendering) {
val ret = (render ++ jsonInCode): RenderOut
- theSession.updateFunctionMap(S.functionMap, spanId, lastRenderTime)
+ theSession.updateFunctionMap(S.functionMap, uniqueId, lastRenderTime)
ret
} else {
_realLastRendering
@@ -1118,7 +1118,7 @@ trait CometActor extends LiftActor with LiftCometActor with BindHelpers {
lastRendering = render ++ jsonInCode
}
- theSession.updateFunctionMap(S.functionMap, spanId, lastRenderTime)
+ theSession.updateFunctionMap(S.functionMap, uniqueId, lastRenderTime)
val rendered: AnswerRender =
AnswerRender(new XmlOrJsCmd(spanId, lastRendering, buildSpan _, notices toList),
View
119 web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala
@@ -371,7 +371,7 @@ class LiftServlet extends Loggable {
} finally {
if (S.functionMap.size > 0) {
- liftSession.updateFunctionMap(S.functionMap, S.uri, millis)
+ liftSession.updateFunctionMap(S.functionMap, S.renderVersion, millis)
S.clearFunctionMap
}
liftSession.notices = S.getNotices
@@ -429,73 +429,76 @@ class LiftServlet extends Loggable {
requestState: Req): Box[LiftResponse] = {
extractVersion(requestState.path.partPath) {
- LiftRules.cometLogger.debug("AJAX Request: " + liftSession.uniqueId + " " + requestState.params)
- tryo {
- LiftSession.onBeginServicing.foreach(_(liftSession, requestState))
- }
-
- val ret = try {
- requestState.param("__lift__GC") match {
- case Full(_) =>
- liftSession.updateFuncByOwner(RenderVersion.get, millis)
- Full(JavaScriptResponse(js.JsCmds.Noop))
+ LiftRules.cometLogger.debug("AJAX Request: " + liftSession.uniqueId + " " + requestState.params)
+ tryo {
+ LiftSession.onBeginServicing.foreach(_(liftSession, requestState))
+ }
- case _ =>
- try {
- val what = flatten(try {
- liftSession.runParams(requestState)
- } catch {
- case ResponseShortcutException(_, Full(to), _) =>
- import js.JsCmds._
- List(RedirectTo(to))
- })
-
- val what2 = what.flatMap {
- case js: JsCmd => List(js)
- case jv: JValue => List(jv)
- case n: NodeSeq => List(n)
- case js: JsCommands => List(js)
- case r: LiftResponse => List(r)
- case s => Nil
- }
+ val ret = try {
+ requestState.param("__lift__GC") match {
+ case Full(_) =>
+ liftSession.updateFuncByOwner(RenderVersion.get, millis)
+ Full(JavaScriptResponse(js.JsCmds.Noop))
- val ret: LiftResponse = what2 match {
- case (json: JsObj) :: Nil => JsonResponse(json)
- case (jv: JValue) :: Nil => JsonResponse(jv)
- case (js: JsCmd) :: xs => {
- (JsCommands(S.noticesToJsCmd :: Nil) &
- ((js :: xs).flatMap {
- case js: JsCmd => List(js)
- case _ => Nil
- }.reverse) &
- S.jsToAppend).toResponse
+ case _ =>
+ try {
+ val what = flatten(try {
+ liftSession.runParams(requestState)
+ } catch {
+ case ResponseShortcutException(_, Full(to), _) =>
+ import js.JsCmds._
+ List(RedirectTo(to))
+ })
+
+ val what2 = what.flatMap {
+ case js: JsCmd => List(js)
+ case jv: JValue => List(jv)
+ case n: NodeSeq => List(n)
+ case js: JsCommands => List(js)
+ case r: LiftResponse => List(r)
+ case s => Nil
}
- case (n: Node) :: _ => XmlResponse(n)
- case (ns: NodeSeq) :: _ => XmlResponse(Group(ns))
- case (r: LiftResponse) :: _ => r
- case _ => JsCommands(S.noticesToJsCmd :: JsCmds.Noop :: S.jsToAppend).toResponse
- }
+ val ret: LiftResponse = what2 match {
+ case (json: JsObj) :: Nil => JsonResponse(json)
+ case (jv: JValue) :: Nil => JsonResponse(jv)
+ case (js: JsCmd) :: xs => {
+ (JsCommands(S.noticesToJsCmd :: Nil) &
+ ((js :: xs).flatMap {
+ case js: JsCmd => List(js)
+ case _ => Nil
+ }.reverse) &
+ S.jsToAppend).toResponse
+ }
- LiftRules.cometLogger.debug("AJAX Response: " + liftSession.uniqueId + " " + ret)
+ case (n: Node) :: _ => XmlResponse(n)
+ case (ns: NodeSeq) :: _ => XmlResponse(Group(ns))
+ case (r: LiftResponse) :: _ => r
+ case _ => JsCommands(S.noticesToJsCmd :: JsCmds.Noop :: S.jsToAppend).toResponse
+ }
- Full(ret)
- } finally {
- liftSession.updateFunctionMap(S.functionMap, RenderVersion.get, millis)
- }
+ LiftRules.cometLogger.debug("AJAX Response: " + liftSession.uniqueId + " " + ret)
+
+ Full(ret)
+ } finally {
+ if (S.functionMap.size > 0) {
+ liftSession.updateFunctionMap(S.functionMap, RenderVersion.get, millis)
+ S.clearFunctionMap
+ }
+ }
+ }
+ } catch {
+ case foc: LiftFlowOfControlException => throw foc
+ case e => NamedPF.applyBox((Props.mode, requestState, e), LiftRules.exceptionHandler.toList);
}
- } catch {
- case foc: LiftFlowOfControlException => throw foc
- case e => NamedPF.applyBox((Props.mode, requestState, e), LiftRules.exceptionHandler.toList);
- }
- tryo {
- LiftSession.onEndServicing.foreach(_(liftSession, requestState, ret))
- }
- ret
+ tryo {
+ LiftSession.onEndServicing.foreach(_(liftSession, requestState, ret))
+ }
+ ret
}
}
- /**
+/**
* An actor that manages continuations from container (Jetty style)
*/
class ContinuationActor(request: Req, session: LiftSession,
View
18 web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
@@ -400,12 +400,16 @@ private[http] object RenderVersion {
func <- sess.findFunc(v).collect {
case f: S.PageStateHolder => f
}
- } yield {
- val tret = ver.doWith(v)(func.runInContext(f))
+ } yield {
+ val tret = ver.doWith(v) {
+ val ret = func.runInContext(f)
- if (S.functionMap.size > 0) {
- sess.updateFunctionMap(S.functionMap, this.get, millis)
- S.clearFunctionMap
+
+ if (S.functionMap.size > 0) {
+ sess.updateFunctionMap(S.functionMap, this.get, millis)
+ S.clearFunctionMap
+ }
+ ret
}
tret
}
@@ -696,7 +700,9 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
*/
def updateFunctionMap(funcs: Map[String, S.AFuncHolder], uniqueId: String, when: Long): Unit = synchronized {
funcs.foreach {
- case (name, func) => messageCallback(name) = func.duplicate(uniqueId)
+ case (name, func) =>
+ messageCallback(name) =
+ if (func.owner == Full(uniqueId)) func else func.duplicate(uniqueId)
}
}
Something went wrong with that request. Please try again.