Handle rethrows in recover more gracefully (#27506)

The idea is that `.recover { xyz => throw newException }` is common enough
not to log an ERROR message just because we didn't catch it in the Recover stage.

On the other hand, using `mapError` can be a better choice if you just want to
map the error (but there might be other occurrences where a partial function is not
enough to avoid throwing an error from recover).
This commit is contained in:
Johannes Rudolph 2019-08-28 10:44:02 +02:00 committed by Johan Andrén
parent c03cec2979
commit f51dc373be
2 changed files with 16 additions and 3 deletions

View file

@ -273,8 +273,8 @@ private[stream] object Collect {
}
}
override def onUpstreamFailure(ex: Throwable): Unit = {
pf.applyOrElse(ex, NotApplied) match {
override def onUpstreamFailure(ex: Throwable): Unit =
try pf.applyOrElse(ex, NotApplied) match {
case NotApplied => failStage(ex)
case result: T @unchecked => {
if (isAvailable(out)) {
@ -284,8 +284,9 @@ private[stream] object Collect {
recovered = Some(result)
}
}
} catch {
case NonFatal(ex) => failStage(ex)
}
}
setHandlers(in, out, this)
}