Uploaded image for project: '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
          }
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: