Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid printing RejectedExectionExeption stack trace after cancellation #4058

Merged
merged 5 commits into from Apr 11, 2018

Conversation

Projects
None yet
3 participants
@retronym
Copy link
Member

commented Apr 3, 2018

Before:

[warn] /Users/jz/code/zinc/internal/zinc-apiinfo/src/main/scala/xsbt/api/Visit.scala:187:19: parameter value s in method visitString is never used
[warn]   def visitString(s: String): Unit = ()
[warn]                   ^
^C
[warn] Canceling execution...
[warn] 10 warnings found
[info] Compilation has been cancelled
[error] java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ExecutorCompletionService$QueueingFuture@33ec70dd rejected from java.util.concurrent.ThreadPoolExecutor@4b832de6[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1410]
[error]     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
[error]     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
[error]     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
[error]     at java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:181)
[error]     at sbt.CompletionService$.submit(CompletionService.scala:36)
[error]     at sbt.ConcurrentRestrictions$$anon$4.submitValid(ConcurrentRestrictions.scala:176)
[error]     at sbt.ConcurrentRestrictions$$anon$4.submit(ConcurrentRestrictions.scala:165)
[error]     at sbt.Execute.submit(Execute.scala:262)
[error]     at sbt.Execute.ready(Execute.scala:242)
[error]     at sbt.Execute.notifyDone(Execute.scala:181)
[error]     at sbt.Execute.$anonfun$retire$2(Execute.scala:152)
[error]     at sbt.Execute.$anonfun$retire$2$adapted(Execute.scala:151)
[error]     at scala.collection.immutable.List.foreach(List.scala:389)
[error]     at sbt.Execute.retire(Execute.scala:151)
[error]     at sbt.Execute.$anonfun$work$2(Execute.scala:279)
[error]     at sbt.Execute$$anon$1.process(Execute.scala:24)
[error]     at sbt.Execute.next$1(Execute.scala:104)
[error]     at sbt.Execute.processAll(Execute.scala:107)
[error]     at sbt.Execute.runKeep(Execute.scala:84)
[error]     at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:387)
[error]     at sbt.EvaluateTask$.run$1(EvaluateTask.scala:386)
[error]     at sbt.EvaluateTask$.runTask(EvaluateTask.scala:405)
[error]     at sbt.internal.Aggregation$.$anonfun$timedRun$4(Aggregation.scala:100)
[error]     at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:331)
[error]     at sbt.internal.Aggregation$.timedRun(Aggregation.scala:98)
[error]     at sbt.internal.Aggregation$.runTasks(Aggregation.scala:111)
[error]     at sbt.internal.Aggregation$.$anonfun$applyTasks$1(Aggregation.scala:68)
[error]     at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error]     at sbt.internal.Aggregation$.$anonfun$evaluatingParser$11(Aggregation.scala:220)
[error]     at sbt.internal.Act$.$anonfun$actParser0$3(Act.scala:387)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:154)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:137)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error]     at sbt.State$$anon$1.process(State.scala:248)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:137)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:137)
[error]     at sbt.MainLoop$.run(MainLoop.scala:130)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:108)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:102)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:58)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:43)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]     at sbt.StandardMain$.runManaged(Main.scala:113)
[error]     at sbt.xMain.run(Main.scala:76)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error]     at xsbt.boot.Boot$.main(Boot.scala:17)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ExecutorCompletionService$QueueingFuture@33ec70dd rejected from java.util.concurrent.ThreadPoolExecutor@4b832de6[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1410]
[error] Use 'last' for the full log.

After:

sbt:zinc Root> ;zincIvyIntegration/cleanClasses;zincIvyIntegration/compile
[success] Total time: 0 s, completed 03/04/2018 2:24:33 PM
[info] Compiling 5 Scala sources and 1 Java source to /Users/jz/code/zinc/internal/zinc-ivy-integration/target/scala-2.12/classes ...
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ResourceLoader.scala:14:42: parameter value classLoader in method getPropertiesFor is never used
[warn]   def getPropertiesFor(resource: String, classLoader: ClassLoader): Properties = {
[warn]                                          ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:13:17: Unused import
[warn] import java.net.URLClassLoader
[warn]                 ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:137:26: Unused import
[warn]       import sbt.io.Path.toURLs
[warn]                          ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:94:30: The outer reference in this type test cannot be checked at run time.
[warn]     private final case class ScalaArtifacts(compiler: File, library: File, others: Vector[File])
[warn]                              ^
^C
[warn] Canceling execution...
[warn] four warnings found
[info] Compilation has been cancelled
[error] Total time: 1 s, completed 03/04/2018 2:24:35 PM

Best served with scala/scala#6479

The Scala version upgrade was to avoid a bug in -Xlint:unused in 2.12.4 (fixed in 2.12.5) that I ran into.

Fixes #3958

retronym added some commits Apr 3, 2018

Avoid printing RejectedExectionExeption stack trace after cancellation
Before:

```
[warn] /Users/jz/code/zinc/internal/zinc-apiinfo/src/main/scala/xsbt/api/Visit.scala:187:19: parameter value s in method visitString is never used
[warn]   def visitString(s: String): Unit = ()
[warn]                   ^
^C
[warn] Canceling execution...
[warn] 10 warnings found
[info] Compilation has been cancelled
[error] java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ExecutorCompletionService$QueueingFuture@33ec70dd rejected from java.util.concurrent.ThreadPoolExecutor@4b832de6[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1410]
[error]     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
[error]     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
[error]     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
[error]     at java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:181)
[error]     at sbt.CompletionService$.submit(CompletionService.scala:36)
[error]     at sbt.ConcurrentRestrictions$$anon$4.submitValid(ConcurrentRestrictions.scala:176)
[error]     at sbt.ConcurrentRestrictions$$anon$4.submit(ConcurrentRestrictions.scala:165)
[error]     at sbt.Execute.submit(Execute.scala:262)
[error]     at sbt.Execute.ready(Execute.scala:242)
[error]     at sbt.Execute.notifyDone(Execute.scala:181)
[error]     at sbt.Execute.$anonfun$retire$2(Execute.scala:152)
[error]     at sbt.Execute.$anonfun$retire$2$adapted(Execute.scala:151)
[error]     at scala.collection.immutable.List.foreach(List.scala:389)
[error]     at sbt.Execute.retire(Execute.scala:151)
[error]     at sbt.Execute.$anonfun$work$2(Execute.scala:279)
[error]     at sbt.Execute$$anon$1.process(Execute.scala:24)
[error]     at sbt.Execute.next$1(Execute.scala:104)
[error]     at sbt.Execute.processAll(Execute.scala:107)
[error]     at sbt.Execute.runKeep(Execute.scala:84)
[error]     at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:387)
[error]     at sbt.EvaluateTask$.run$1(EvaluateTask.scala:386)
[error]     at sbt.EvaluateTask$.runTask(EvaluateTask.scala:405)
[error]     at sbt.internal.Aggregation$.$anonfun$timedRun$4(Aggregation.scala:100)
[error]     at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:331)
[error]     at sbt.internal.Aggregation$.timedRun(Aggregation.scala:98)
[error]     at sbt.internal.Aggregation$.runTasks(Aggregation.scala:111)
[error]     at sbt.internal.Aggregation$.$anonfun$applyTasks$1(Aggregation.scala:68)
[error]     at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error]     at sbt.internal.Aggregation$.$anonfun$evaluatingParser$11(Aggregation.scala:220)
[error]     at sbt.internal.Act$.$anonfun$actParser0$3(Act.scala:387)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:154)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:137)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error]     at sbt.State$$anon$1.process(State.scala:248)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:137)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:137)
[error]     at sbt.MainLoop$.run(MainLoop.scala:130)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:108)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:102)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:58)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:43)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]     at sbt.StandardMain$.runManaged(Main.scala:113)
[error]     at sbt.xMain.run(Main.scala:76)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error]     at xsbt.boot.Boot$.main(Boot.scala:17)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ExecutorCompletionService$QueueingFuture@33ec70dd rejected from java.util.concurrent.ThreadPoolExecutor@4b832de6[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1410]
[error] Use 'last' for the full log.
```

After:

```
sbt:zinc Root> ;zincIvyIntegration/cleanClasses;zincIvyIntegration/compile
[success] Total time: 0 s, completed 03/04/2018 2:24:33 PM
[info] Compiling 5 Scala sources and 1 Java source to /Users/jz/code/zinc/internal/zinc-ivy-integration/target/scala-2.12/classes ...
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ResourceLoader.scala:14:42: parameter value classLoader in method getPropertiesFor is never used
[warn]   def getPropertiesFor(resource: String, classLoader: ClassLoader): Properties = {
[warn]                                          ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:13:17: Unused import
[warn] import java.net.URLClassLoader
[warn]                 ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:137:26: Unused import
[warn]       import sbt.io.Path.toURLs
[warn]                          ^
[warn] /Users/jz/code/zinc/internal/zinc-ivy-integration/src/main/scala/sbt/internal/inc/ZincComponentCompiler.scala:94:30: The outer reference in this type test cannot be checked at run time.
[warn]     private final case class ScalaArtifacts(compiler: File, library: File, others: Vector[File])
[warn]                              ^
^C
[warn] Canceling execution...
[warn] four warnings found
[info] Compilation has been cancelled
[error] Total time: 1 s, completed 03/04/2018 2:24:35 PM
```

Best served with scala/scala#6479

Fixes #3958

@eed3si9n eed3si9n added the in progress label Apr 3, 2018

@@ -387,7 +388,11 @@ object EvaluateTask {
val results = x.runKeep(root)(service)
storeValuesForPrevious(results, state, streams)
applyResults(results, state, root)
} catch { case inc: Incomplete => (state, Inc(inc)) } finally shutdown()
} catch {
case _: RejectedExecutionException =>

This comment has been minimized.

Copy link
@retronym

retronym Apr 3, 2018

Author Member

I would have been happier to translate this into an Incomplete in the layer below, but I got lost trying to navigate the code. IntelliJ seems unable to correctly import the SBT project at the moment, which makes my life a bit harder.

This comment has been minimized.

Copy link
@dwijnand

This comment has been minimized.

Copy link
@retronym

retronym Apr 3, 2018

Author Member

LGTM, merged. We could squash this PR on merge.

@retronym

This comment has been minimized.

Copy link
Member Author

commented Apr 3, 2018

The RejectedExecutionException is thrown in

val future = completion.submit { new Callable[T] { def call = work() } }

Called by

CompletionService.submit(wrappedWork, jservice)

@retronym retronym requested a review from eed3si9n Apr 3, 2018

@retronym

This comment has been minimized.

Copy link
Member Author

commented Apr 3, 2018

Related question: What would we need to do to make cancellable in Global := true the default? I expect that 90% of users don't know about the feature, so the impact of improvements like this and scala/scala#6479 is smaller than we'd like.

@eed3si9n

This comment has been minimized.

Copy link
Member

commented Apr 3, 2018

Related question: What would we need to do to make cancellable in Global := true the default? I expect that 90% of users don't know about the feature, so the impact of improvements like this and scala/scala#6479 is smaller than we'd like.

There's an issue called #3252 proposing it. We can flip it on for 1.2.0, since I'd like to keep 1.1.x bug fixes only.

dwijnand added some commits Apr 3, 2018

Merge pull request #1 from dwijnand/topic/quietly-cancel
Catch RejectedExecutionException into an Incomplete

@dwijnand dwijnand modified the milestones: 1.1.3, 1.1.5 Apr 11, 2018

@dwijnand dwijnand merged commit a8c1239 into sbt:1.1.x Apr 11, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@dwijnand dwijnand removed the in progress label Apr 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.