Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cloese #1001. Do something nice for Tomcat

  • Loading branch information...
commit f7da1d3e47edd18fd90850e88e0fd520d0622566 1 parent 4304e04
@dpp dpp authored
View
20 core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala
@@ -25,19 +25,23 @@ import java.util.concurrent._
*/
object LAPinger {
- /** The underlying <code>java.util.concurrent.ScheduledExecutor</code> */
+ /**The underlying <code>java.util.concurrent.ScheduledExecutor</code> */
private var service = Executors.newSingleThreadScheduledExecutor(TF)
/**
* Re-create the underlying <code>SingleThreadScheduledExecutor</code>
*/
- def restart: Unit = synchronized { if ((service eq null) || service.isShutdown)
- service = Executors.newSingleThreadScheduledExecutor(TF) }
+ def restart: Unit = synchronized {
+ if ((service eq null) || service.isShutdown)
+ service = Executors.newSingleThreadScheduledExecutor(TF)
+ }
/**
* Shut down the underlying <code>SingleThreadScheduledExecutor</code>
*/
- def shutdown: Unit = synchronized { service.shutdown }
+ def shutdown: Unit = synchronized {
+ service.shutdown
+ }
/**
* Schedules the sending of a message to occur after the specified delay.
@@ -47,7 +51,9 @@ object LAPinger {
*/
def schedule[T](to: SpecializedLiftActor[T], msg: T, delay: Long): ScheduledFuture[Unit] = {
val r = new Callable[Unit] {
- def call: Unit = { to ! msg }
+ def call: Unit = {
+ to ! msg
+ }
}
try {
service.schedule(r, delay, TimeUnit.MILLISECONDS)
@@ -65,10 +71,12 @@ case class PingerException(msg: String, e: Throwable) extends RuntimeException(m
private object TF extends ThreadFactory {
val threadFactory = Executors.defaultThreadFactory()
- def newThread(r: Runnable) : Thread = {
+
+ def newThread(r: Runnable): Thread = {
val d: Thread = threadFactory.newThread(r)
d setName "ActorPinger"
d setDaemon true
+ d setContextClassLoader null
d
}
}
View
1  core/util/src/main/scala/net/liftweb/util/Schedule.scala
@@ -196,6 +196,7 @@ private object TF extends ThreadFactory {
val d: Thread = threadFactory.newThread(r)
d setName "Lift Scheduler"
d setDaemon true
+ d setContextClassLoader null
d
}
}
View
34 core/util/src/main/scala/net/liftweb/util/SoftReferenceCache.scala
@@ -17,7 +17,7 @@
package net.liftweb
package util
-import java.lang.ref.{ReferenceQueue,SoftReference};
+import java.lang.ref.{ReferenceQueue, SoftReference};
import java.util._
import Map._
import concurrent.locks._
@@ -26,6 +26,7 @@ import common._
import util._
import Helpers._
import Schedule._
+import java.lang.Thread._
/**
@@ -44,7 +45,7 @@ object SoftReferenceCache {
/**
* Create a new SoftReferenceCache instance
*/
- def apply[K, V](size: Int) = new SoftReferenceCache[K,V](size)
+ def apply[K, V](size: Int) = new SoftReferenceCache[K, V](size)
/**
* Initialize the orphan keys monitor
@@ -52,12 +53,13 @@ object SoftReferenceCache {
def initialize = {
// A daemon thread is more approapriate here then an Actor as
// we'll do blocking reads from the reference queue
- val thread = new Thread(new Runnable(){
- def run(){
- processQueue
- }
- })
+ val thread = new Thread(new Runnable() {
+ def run() {
+ processQueue
+ }
+ })
thread.setDaemon(true)
+ thread setContextClassLoader null
thread.start
}
@@ -72,7 +74,7 @@ object SoftReferenceCache {
while (!terminated) {
tryo {
// Wait 30 seconds for something to appear in the queue.
- val sftVal = refQueue.remove(30000).asInstanceOf[SoftValue[_,_]];
+ val sftVal = refQueue.remove(30000).asInstanceOf[SoftValue[_, _]];
if (sftVal != null) {
sftVal.cache.remove(sftVal.key);
}
@@ -82,6 +84,7 @@ object SoftReferenceCache {
}
case object ProcessQueue
+
case object Done
/**
@@ -118,10 +121,10 @@ class SoftReferenceCache[K, V](cacheSize: Int) {
def apply(key: K): Box[V] = lock(readLock) {
Box.!!(cache.get(key)) match {
case Full(value) =>
- Box.!!(value.get) or {
- remove(key);
- Empty
- }
+ Box.!!(value.get) or {
+ remove(key);
+ Empty
+ }
case _ => Empty
}
}
@@ -131,7 +134,7 @@ class SoftReferenceCache[K, V](cacheSize: Int) {
* @param tuple: (K, V)*
* @return this
*/
- def += (tuple: (K, V)*) = {
+ def +=(tuple: (K, V)*) = {
lock(writeLock) {
for (t <- tuple) yield {
cache.put(t._1, new SoftValue(t._1, t._2, this, SoftReferenceCache.refQueue));
@@ -162,7 +165,8 @@ class SoftValue[K, V](k: K,
v: V,
lruCache: SoftReferenceCache[K, V],
queue: ReferenceQueue[Any]) extends SoftReference[V](v, queue) {
- def key: K = k
- def cache: SoftReferenceCache[K, V] = lruCache
+ def key: K = k
+
+ def cache: SoftReferenceCache[K, V] = lruCache
}
Please sign in to comment.
Something went wrong with that request. Please try again.