scala.NotImplementedError: an implementation is missing

Scala JIRA | James Roper | 4 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    The fork join execution context loses fatal exceptions. It should allow them to be handled by the threads uncaught exception handler, so that they can be logged. But it doesn't, they get lost, not reported anywhere. Here is an example in the repl: {noformat} scala> import scala.concurrent._ import scala.concurrent._ scala> val ec = scala.concurrent.ExecutionContext.global ec: scala.concurrent.ExecutionContextExecutor = scala.concurrent.impl.ExecutionContextImpl@4a640180 scala> val f = Future[Unit](throw new NotImplementedError())(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@3ec9e1f9 {noformat} Nothing happens. What I expected is for my NotImplementedError to be at least handled by the uncaught exception handler, and logged. Now, I know the uncaught exception handler is there and working: {noformat} scala> val f = Future[Unit](Thread.currentThread.getUncaughtExceptionHandler.uncaughtException(Thread.currentThread, new NotImplementedError()))(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@4aac53a8 Exception in thread "ForkJoinPool-1-worker-1" scala.NotImplementedError: an implementation is missing at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply$mcV$sp(<console>:11) at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11) at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) {noformat} And if I use a different execution context, such as a Java executor, it works as expected: {noformat} scala> val es = java.util.concurrent.Executors.newSingleThreadExecutor es: java.util.concurrent.ExecutorService = java.util.concurrent.Executors$FinalizableDelegatedExecutorService@10cd508f scala> val ec = ExecutionContext.fromExecutorService(es) ec: scala.concurrent.ExecutionContextExecutorService = scala.concurrent.impl.ExecutionContextImpl$$anon$1@11e9c5a7 scala> val f = Future[Unit](throw new NotImplementedError())(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@7309eabd Exception in thread "pool-1-thread-1" scala.NotImplementedError: an implementation is missing at $line69.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:12) at $line69.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:12) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) {noformat}

    Scala JIRA | 4 years ago | James Roper
    scala.NotImplementedError: an implementation is missing
  2. 0

    The fork join execution context loses fatal exceptions. It should allow them to be handled by the threads uncaught exception handler, so that they can be logged. But it doesn't, they get lost, not reported anywhere. Here is an example in the repl: {noformat} scala> import scala.concurrent._ import scala.concurrent._ scala> val ec = scala.concurrent.ExecutionContext.global ec: scala.concurrent.ExecutionContextExecutor = scala.concurrent.impl.ExecutionContextImpl@4a640180 scala> val f = Future[Unit](throw new NotImplementedError())(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@3ec9e1f9 {noformat} Nothing happens. What I expected is for my NotImplementedError to be at least handled by the uncaught exception handler, and logged. Now, I know the uncaught exception handler is there and working: {noformat} scala> val f = Future[Unit](Thread.currentThread.getUncaughtExceptionHandler.uncaughtException(Thread.currentThread, new NotImplementedError()))(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@4aac53a8 Exception in thread "ForkJoinPool-1-worker-1" scala.NotImplementedError: an implementation is missing at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply$mcV$sp(<console>:11) at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11) at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) {noformat} And if I use a different execution context, such as a Java executor, it works as expected: {noformat} scala> val es = java.util.concurrent.Executors.newSingleThreadExecutor es: java.util.concurrent.ExecutorService = java.util.concurrent.Executors$FinalizableDelegatedExecutorService@10cd508f scala> val ec = ExecutionContext.fromExecutorService(es) ec: scala.concurrent.ExecutionContextExecutorService = scala.concurrent.impl.ExecutionContextImpl$$anon$1@11e9c5a7 scala> val f = Future[Unit](throw new NotImplementedError())(ec) f: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@7309eabd Exception in thread "pool-1-thread-1" scala.NotImplementedError: an implementation is missing at $line69.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:12) at $line69.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:12) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) {noformat}

    Scala JIRA | 4 years ago | James Roper
    scala.NotImplementedError: an implementation is missing

    Root Cause Analysis

    1. scala.NotImplementedError

      an implementation is missing

      at $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply$mcV$sp()
    2. $line53
      $read$$iw$$iw$$iw$$iw$$anonfun$1.apply
      1. $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply$mcV$sp(<console>:11)
      2. $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11)
      3. $line53.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:11)
      3 frames
    3. Scala
      ForkJoinWorkerThread.run
      1. scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
      2. scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
      3. scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417)
      4. scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262)
      5. scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
      6. scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478)
      7. scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
      7 frames