Browse files

Closes #1036. Makes nulling the context class loader optional

  • Loading branch information...
1 parent 5884fae commit 4776886b0be6168f53915e821734e47eb553cc2e @dpp dpp committed Jul 1, 2011
View
18 core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala
@@ -20,6 +20,20 @@ package actor
import java.util.concurrent._
/**
+ * Rules for dealing with thread pools, both in lift-actor and
+ * in lift-util
+ */
+object ThreadPoolRules {
+ /**
+ * When threads are created in the thread factories, should
+ * they null the context class loader. By default false,
+ * but it you set it to true, Tomcat complains less about stuff.
+ * Must be set in the first line of Boot.scala
+ */
+ @volatile var nullContextClassLoader: Boolean = false
+}
+
+/**
* The ActorPing object schedules an actor to be ping-ed with a given message at specific intervals.
* The schedule methods return a ScheduledFuture object which can be cancelled if necessary
*/
@@ -76,7 +90,9 @@ private object TF extends ThreadFactory {
val d: Thread = threadFactory.newThread(r)
d setName "ActorPinger"
d setDaemon true
- d setContextClassLoader null
+ if (ThreadPoolRules.nullContextClassLoader) {
+ d setContextClassLoader null
+ }
d
}
}
View
6 core/util/src/main/scala/net/liftweb/util/Schedule.scala
@@ -20,6 +20,7 @@ package util
import java.util.concurrent._
import Helpers.TimeSpan
import common._
+import actor.ThreadPoolRules
class ScheduleJBridge {
def schedule: Schedule = Schedule
@@ -196,7 +197,10 @@ private object TF extends ThreadFactory {
val d: Thread = threadFactory.newThread(r)
d setName "Lift Scheduler"
d setDaemon true
- d setContextClassLoader null
+
+ if (ThreadPoolRules.nullContextClassLoader) {
+ d setContextClassLoader null
+ }
d
}
}

0 comments on commit 4776886

Please sign in to comment.