You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "lolgab (via GitHub)" <gi...@apache.org> on 2023/05/22 14:30:32 UTC

[GitHub] [incubator-pekko-management] lolgab commented on pull request #74: Replace future flatMap + recoverWith combo with transform

lolgab commented on PR #74:
URL: https://github.com/apache/incubator-pekko-management/pull/74#issuecomment-1557326578

   I think this might introduce a bug since `transform` is not a `PartialFuction`.
   ```scala
   @ Future.failed(new Exception("BOOM")).transform {
       case Success(v) => Success(v)
       case Failure(_: IllegalArgumentException) => Success("It's fine")
     }
   res14: Future[String] = Future(Failure(scala.MatchError: Failure(java.lang.Exception: BOOM) (of class scala.util.Failure)))
   
   @ Future.failed(new Exception("BOOM")).recoverWith {
       case _: IllegalArgumentException => Future.successful("It's fine")
     }
   res15: Future[String] = Future(Failure(java.lang.Exception: BOOM))
   ```
   
   It changes behavior since now all the exceptions not handled in `transform` are wrapped in a `MatchError`.
   
   I think you need to add a `case f: Failure => f` at the end and make the `match` exhaustive.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org