Skip to content

Commit

Permalink
Closes lift#1036. Makes nulling the context class loader optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Jul 1, 2011
1 parent 5884fae commit 4776886
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 17 additions & 1 deletion core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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
Expand Down Expand Up @@ -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
}
}
Expand Down
6 changes: 5 additions & 1 deletion core/util/src/main/scala/net/liftweb/util/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package util
import java.util.concurrent._
import Helpers.TimeSpan
import common._
import actor.ThreadPoolRules

class ScheduleJBridge {
def schedule: Schedule = Schedule
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 4776886

Please sign in to comment.