lift/framework

MockWeb's LiftSession.destroySession raises exception in console

joescii opened this issue · 0 comments

While migrating a Lift app from 2.6 to 3.1 and found what turned out to be a benign exception in the console. It occurs if you happen to destroy the LiftSession used in MockWeb.testS.

For instance, following code in a spec2 Specification...

MockWeb.testS("http://localhost:9090")(
  S.session.map(_.destroySession())
)

... will cause the following exception in the console:

14:48:02.269 [pool-10-thread-1] ERROR net.liftweb.actor.ActorLogger - Actor threw an exception
java.lang.NullPointerException: null
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) ~[na:1.8.0_131]
at net.liftweb.http.SessionMaster$$anonfun$3.applyOrElse(SessionMaster.scala:205) ~[lift-webkit_2.11-3.1.0.jar:3.1.0]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) ~[scala-library-2.11.11.jar:1.0.1]
at net.liftweb.actor.LiftActor$class.execTranslate(LiftActor.scala:504) ~[lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.http.SessionMaster$.execTranslate(SessionMaster.scala:42) [lift-webkit_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$proc2(LiftActor.scala:305) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply$mcV$sp(LiftActor.scala:227) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:227) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:227) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$class.around(LiftActor.scala:241) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.http.SessionMaster$.around(SessionMaster.scala:42) [lift-webkit_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$processMailbox(LiftActor.scala:226) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.SpecializedLiftActor$$anonfun$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiftActor.scala:190) [lift-actor_2.11-3.1.0.jar:3.1.0]
at net.liftweb.actor.LAScheduler$$anonfun$9$$anon$2$$anon$3.run(LiftActor.scala:76) [lift-actor_2.11-3.1.0.jar:3.1.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

This doesn't happen in 2.6.

The good news is the test doesn't fail. It just cost us some time discovering where this new exception was coming from.

Note the exception happens even when destroying the LiftSession outside of the testS function (which happened to be what our test was trying to do)

I have a sample project demonstrating the behavior. Run sbt clean update test in my 2.6 and 3.1 branches.

Mailing List thread: https://groups.google.com/forum/#!topic/liftweb/lHHJZJfiWcs