Skip to content

Lambdas as Callable hang REPL #10064

Closed
Closed
@scabug

Description

@scabug

Submitting a lambda as a callable and retrieving the future on the same line causes the REPL to hang.

Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.

scala> import java.util.concurrent._
import java.util.concurrent._

scala> val exec = Executors.newCachedThreadPool
exec: java.util.concurrent.ExecutorService = java.util.concurrent.ThreadPoolExecutor@7512870b[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]

OK, because not a lambda:

scala> exec.submit(new Callable[String] { def call = "foo" }).get
res0: String = foo

OK, because retrieval separate from submission:

scala> val f = exec.submit(() => "foo")
f: java.util.concurrent.Future[String] = java.util.concurrent.FutureTask@2c81f298

scala> f.get
res1: String = foo

Hangs:

scala> exec.submit(() => "foo").get

This was discovered in the real world by attempting scalaz.concurrent.Task("foo").run, which also hangs.

The same snippets all complete successfully on Scala 2.11.8.

Maybe related to SI-9076?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions