Scala Programming Language
  1. Scala Programming Language
  2. SI-6913

Future.fallbackTo does not preserve first Future's Failure per documentation

    Details

      Description

      scala.concurrent.Future fallbackTo method is documented as returning the failure of the first future if both futures fail, but instead it returns the failure of the second future. Maybe it should be something like this?

          def fallbackTo[U >: T](that: Future[U]): Future[U] = {
            val p = Promise[U]()
            onComplete {
              case s @ Success(_) => p complete s
              case f =>  that.onComplete {
                case s @ Success(_) => p complete s
                case _ => p complete f
              }
            }
            p.future
          }
      

        Activity

        Hide
        Viktor Klang added a comment -
        Show
        Viktor Klang added a comment - Proposed fix here: https://github.com/viktorklang/scala/pull/5/commits
        Hide
        Heather Miller added a comment -

        That PR somehow got chunked up and this fix since got lost. New PR:
        https://github.com/scala/scala/pull/3181

        Show
        Heather Miller added a comment - That PR somehow got chunked up and this fix since got lost. New PR: https://github.com/scala/scala/pull/3181

          People

          • Assignee:
            Unassigned
            Reporter:
            Bob Hiestand
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development