From 5a0b2c1cfaec7f83ebe061298dd0adc4613a2835 Mon Sep 17 00:00:00 2001 From: "He-Pin(kerr)" Date: Mon, 18 Mar 2024 17:54:57 +0800 Subject: [PATCH] chore: Add a base termination for abrupt stream termination exceptions. (#1201) --- .../org/apache/pekko/stream/ActorMaterializer.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stream/src/main/scala/org/apache/pekko/stream/ActorMaterializer.scala b/stream/src/main/scala/org/apache/pekko/stream/ActorMaterializer.scala index baf70d9e2f0..b692c3d3130 100644 --- a/stream/src/main/scala/org/apache/pekko/stream/ActorMaterializer.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/ActorMaterializer.scala @@ -267,14 +267,20 @@ abstract class ActorMaterializer extends Materializer with MaterializerLoggingPr */ class MaterializationException(msg: String, cause: Throwable = null) extends RuntimeException(msg, cause) +/** + * A base exception for abrupt stream termination. + */ +sealed class AbruptStreamTerminationException(msg: String, cause: Throwable = null) + extends RuntimeException(msg, cause) + with NoStackTrace + /** * This exception signals that an actor implementing a Reactive Streams Subscriber, Publisher or Processor * has been terminated without being notified by an onError, onComplete or cancel signal. This usually happens * when an ActorSystem is shut down while stream processing actors are still running. */ final case class AbruptTerminationException(actor: ActorRef) - extends RuntimeException(s"Processor actor [$actor] terminated abruptly") - with NoStackTrace + extends AbruptStreamTerminationException(s"Processor actor [$actor] terminated abruptly") /** * Signal that the operator was abruptly terminated, usually seen as a call to `postStop` of the `GraphStageLogic` without @@ -282,9 +288,8 @@ final case class AbruptTerminationException(actor: ActorRef) * the actor running the graph is killed, which happens when the materializer or actor system is terminated. */ final class AbruptStageTerminationException(logic: GraphStageLogic) - extends RuntimeException( + extends AbruptStreamTerminationException( s"GraphStage [$logic] terminated abruptly, caused by for example materializer or actor system termination.") - with NoStackTrace object ActorMaterializerSettings {