Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

LiftRules.throwOnOutOfScopeVarAccess broken? #1063

Open
indrajitr opened this Issue Jul 1, 2011 · 2 comments

Comments

Projects
None yet
4 participants
Owner

indrajitr commented Jul 1, 2011

Copied from http://groups.google.com/group/liftweb/browse_thread/thread/54e059516001a518

For example, trying to use
a SessionVar before the session has been created shouldn't just refuse to be set. It
would be nice to have an exception reporting the problem.

I think your points are valid to a certain degree, but for this
specific problem there's a solution in LiftRules:

/**

  • Should an exception be thrown on out of scope Session and RequestVar
  • access. By default, no.
    */
    @volatile var throwOnOutOfScopeVarAccess: Boolean = false

/Jeppe

Thanks for the pointer, but I don't think it's working. After messing around with it in my own project, I did the following:

  1. downloaded the examples from https://github.com/lift/lift_23_sbt.git

  2. Compiled and ran fine using sbt

  3. Added

    // Find out if we access SessionVars or RequestVars inappropriately..
    LiftRules.throwOnOutOfScopeVarAccess = true

    as the last line in Boot.boot

  4. Ran again and it threw an exception:

[info] == jetty-run ==
[success] Successful.
[info]
[info] Total time: 2 s, completed Jun 30, 2011 11:48:02 AM

11:48:04.848 [1193485506@qtp-1743791445-0] ERROR net.liftweb.http.LiftRules$$anon$1 - Exception being returned to browser when processing /: Message: java.lang.IllegalAccessException: Access to SessionVar outside a request or comet actor scope
net.liftweb.http.SessionVar.findFunc(Vars.scala:71)
net.liftweb.util.AnyVarTrait$$anonfun$is$1.apply(AnyVar.scala:137)
net.liftweb.http.SessionVar.doSync(Vars.scala:125)
net.liftweb.util.AnyVarTrait$class.is(AnyVar.scala:136)
net.liftweb.util.AnyVar.is(AnyVar.scala:89)
net.liftweb.util.AnyVarTrait$class.get(AnyVar.scala:161)
net.liftweb.util.AnyVar.get(AnyVar.scala:89)
net.liftweb.util.StackableMaker$class.find(Maker.scala:150)
net.liftweb.http.Factory$FactoryMaker.find(Factory.scala:37)
net.liftweb.http.Factory$FactoryMaker$$anonfun$make$1.apply(Factory.scala:87)
net.liftweb.http.Factory$FactoryMaker$$anonfun$make$1.apply(Factory.scala:87)
net.liftweb.common.EmptyBox.or(Box.scala:563)
net.liftweb.http.Factory$FactoryMaker.make(Factory.scala:87)
net.liftweb.http.Factory$FactoryMaker.vend(Factory.scala:82)
net.liftweb.http.S$class.statelessInit(S.scala:1186)
net.liftweb.http.LiftServlet.doService(LiftServlet.scala:244)
net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:122)
net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:121)

(lots omitted)

@ghost ghost assigned dpp Mar 1, 2012

Owner

Shadowfiend commented May 11, 2014

< headscratch > This seems like exactly the behavior that that variable is meant to set up? O.o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment