Skip to content
This repository
Browse code

SI-7146 - Fixing checkinit bug in ExecutionContextImpl and adding test

  • Loading branch information...
commit bb067d31e4f02cc605146c676031bbfccac639c2 1 parent 123161b
Viktor Klang (√) authored February 19, 2013
8  src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -19,16 +19,16 @@ import scala.util.control.NonFatal
19 19
 
20 20
 
21 21
 private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: Throwable => Unit) extends ExecutionContextExecutor {
  22
+  // Placed here since the creation of the executor needs to read this val
  23
+  private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
  24
+    def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause)
  25
+  }
22 26
 
23 27
   val executor: Executor = es match {
24 28
     case null => createExecutorService
25 29
     case some => some
26 30
   }
27 31
 
28  
-  private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
29  
-    def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause)
30  
-  }
31  
-
32 32
   // Implement BlockContext on FJP threads
33 33
   class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory { 
34 34
     def wire[T <: Thread](thread: T): T = {
5  test/files/jvm/t7146.check
... ...
@@ -0,0 +1,5 @@
  1
+should be scala.concurrent.impl.ExecutionContextImpl == true
  2
+should be scala.concurrent.forkjoin.ForkJoinPool == true
  3
+should have non-null UncaughtExceptionHandler == true
  4
+should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == true
  5
+should just print out on uncaught == true
23  test/files/jvm/t7146.scala
... ...
@@ -0,0 +1,23 @@
  1
+import java.util.concurrent.Executor
  2
+import scala.concurrent._
  3
+import scala.util.control.NoStackTrace
  4
+
  5
+object Test {
  6
+  def main(args: Array[String]) {
  7
+    println("should be scala.concurrent.impl.ExecutionContextImpl == " +
  8
+      ExecutionContext.global.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl"))
  9
+    val i = ExecutionContext.global.asInstanceOf[{ def executor: Executor }]
  10
+    println("should be scala.concurrent.forkjoin.ForkJoinPool == " +
  11
+      i.executor.toString.startsWith("scala.concurrent.forkjoin.ForkJoinPool"))
  12
+    val u = i.executor.
  13
+             asInstanceOf[{ def getUncaughtExceptionHandler: Thread.UncaughtExceptionHandler }].
  14
+             getUncaughtExceptionHandler
  15
+    println("should have non-null UncaughtExceptionHandler == " + (u ne null))
  16
+    println("should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == " +
  17
+      u.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl"))
  18
+    print("should just print out on uncaught == ")
  19
+    u.uncaughtException(Thread.currentThread, new Throwable {
  20
+      override def printStackTrace() { println("true") }
  21
+    })
  22
+  }
  23
+}

0 notes on commit bb067d3

Please sign in to comment.
Something went wrong with that request. Please try again.