executorservice - How to catch RejectedExecutionException when using Scala futures? -


where should catch rejectedexecutionexceptions when shutting down executor ? tried:

 future {         option(reader.readline)       } oncomplete {         case success(v) =>         case failure(e) => e match {           case ree: rejectedexecutionexception =>           // doesn't work       } 

and :

 try {         future {           option(reader.readline)         } oncomplete {           ...         }       } catch {         case ree: rejectedexecutionexception =>           // doesn't work       } 

also doesn't work. still getting :

exception in thread "pool-99-thread-1" java.util.concurrent.rejectedexecutionexception @ java.util.concurrent.threadpoolexecutor$abortpolicy.rejectedexecution(threadpoolexecutor.java:1768) @ java.util.concurrent.threadpoolexecutor.reject(threadpoolexecutor.java:767) @ java.util.concurrent.threadpoolexecutor.execute(threadpoolexecutor.java:658) @ scala.concurrent.impl.executioncontextimpl.execute(executioncontextimpl.scala:105) @ scala.concurrent.impl.callbackrunnable.executewithvalue(promise.scala:37) @ scala.concurrent.impl.promise$defaultpromise.trycomplete(promise.scala:133) @ scala.concurrent.promise$class.complete(promise.scala:55) @ scala.concurrent.impl.promise$defaultpromise.complete(promise.scala:58) @ scala.concurrent.impl.future$promisecompletingrunnable.run(future.scala:23) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662) 

it must handled rejectedexecutionhandler. either java.util.concurrent.threadpoolexecutor.discardpolicy or custom implementation.

this executor silently passes on rejectedexecutionexception:

val executorservice = new threadpoolexecutor(1, 1, 0l, timeunit.milliseconds, new linkedblockingqueue[runnable], executors.defaultthreadfactory, new discardpolicy) 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -