From 7d5e5daa709fa0042fce51895f67d2ec1f00e744 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 6 Aug 2025 03:44:43 +0100 Subject: [PATCH] use CompletableFuture#failedStage (#2013) --- actor/src/main/scala/org/apache/pekko/dispatch/Future.scala | 1 + .../org/apache/pekko/pattern/FutureTimeoutSupport.scala | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala b/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala index 89bc2507ba..f63292110a 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala @@ -137,6 +137,7 @@ object Futures { /** * Creates an already completed CompletionStage with the specified exception */ + @deprecated("Use `CompletableFuture#failedStage` instead.", since = "2.0.0") def failedCompletionStage[T](ex: Throwable): CompletionStage[T] = { val f = CompletableFuture.completedFuture[T](null.asInstanceOf[T]) f.obtrudeException(ex) diff --git a/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala b/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala index eba3b1e874..f936994601 100644 --- a/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala +++ b/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala @@ -21,7 +21,6 @@ import scala.util.control.NonFatal import org.apache.pekko import pekko.actor._ -import pekko.dispatch.Futures trait FutureTimeoutSupport { @@ -70,7 +69,7 @@ trait FutureTimeoutSupport { implicit ec: ExecutionContext): CompletionStage[T] = if (duration.isFinite && duration.length < 1) { try value - catch { case NonFatal(t) => Futures.failedCompletionStage(t) } + catch { case NonFatal(t) => CompletableFuture.failedStage(t) } } else { val p = new CompletableFuture[T] using.scheduleOnce(duration) { @@ -129,7 +128,7 @@ trait FutureTimeoutSupport { val stage: CompletionStage[T] = try value catch { - case NonFatal(t) => Futures.failedCompletionStage(t) + case NonFatal(t) => CompletableFuture.failedStage(t) } if (stage.toCompletableFuture.isDone) { stage