You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Future.failure(new Exception()).failed does not return a successful future containing the failure, in contrast to Future(new Exception()).failed, which does—the latter being the expected behavior.
{code}scala-core $ sbt console
[info] Starting scala interpreter...
Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_74).
Type in expressions for evaluation. Or try :help.
Viktor Klang (viktorklang) said:
Thank you so much for finding, diagnosing and reporting this issue.
Apologies for the inconvenience, it was a combination of a bad test case with a non-happy-path value.
Regression:
Future.failure(new Exception()).failed does not return a successful future containing the failure, in contrast to Future(new Exception()).failed, which does—the latter being the expected behavior.
{code}scala-core $ sbt console
[info] Starting scala interpreter...
Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_74).
Type in expressions for evaluation. Or try :help.
scala> import scala.concurrent._
import scala.concurrent._
scala> import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.ExecutionContext.Implicits.global
scala> val f = Future.failed(new Exception("error"))
f: scala.concurrent.Future[Nothing] = Future(Failure(java.lang.Exception: error))
scala> f.failed
res0: scala.concurrent.Future[Throwable] = Future(Failure(java.lang.Exception: error))
scala> val f = Future(throw new Exception("error"))
f: scala.concurrent.Future[Nothing] = Future()
scala> f
res1: scala.concurrent.Future[Nothing] = Future(Failure(java.lang.Exception: error))
scala> f.failed
res2: scala.concurrent.Future[Throwable] = Future(Success(java.lang.Exception: error)){code}
Note how res2 differs from res0, even though they both operate on what look like equivalent failed futures (f and res1)
This is because the offending line (https://github.com/scala/scala/blob/2.12.x/src/library/scala/concurrent/impl/Promise.scala#L387)
casts the future without switching the Failure to a Success.
The text was updated successfully, but these errors were encountered: