diff --git a/actor-tests/src/test/java/org/apache/pekko/pattern/PatternsTest.java b/actor-tests/src/test/java/org/apache/pekko/pattern/PatternsTest.java index 1932f8ef75..8008c3b39b 100644 --- a/actor-tests/src/test/java/org/apache/pekko/pattern/PatternsTest.java +++ b/actor-tests/src/test/java/org/apache/pekko/pattern/PatternsTest.java @@ -488,6 +488,7 @@ public class PatternsTest extends JUnitSuite { } @Test + @SuppressWarnings("deprecation") public void testCompletedStageWithTimeout() throws Exception { final String expected = "Hello"; final CompletionStage delayedStage = @@ -501,6 +502,7 @@ public class PatternsTest extends JUnitSuite { } @Test + @SuppressWarnings("deprecation") public void testFailedCompletedStageWithTimeout() throws Exception { final CompletionStage delayedStage = Patterns.timeout( @@ -521,6 +523,7 @@ public class PatternsTest extends JUnitSuite { } @Test + @SuppressWarnings("deprecation") public void testCompletedWithTimeout() throws Exception { final CompletionStage delayedStage = Patterns.timeout(Duration.ofMillis(200), system.scheduler(), ec, CompletableFuture::new); 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 f936994601..a608172552 100644 --- a/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala +++ b/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala @@ -123,6 +123,7 @@ trait FutureTimeoutSupport { * if the provided value is not completed within the specified duration. * @since 1.2.0 */ + @deprecated("Use `CompletableFuture#orTimeout instead.", "Pekko 2.0.0") def timeoutCompletionStage[T](duration: FiniteDuration, using: Scheduler)(value: => CompletionStage[T])( implicit ec: ExecutionContext): CompletionStage[T] = { val stage: CompletionStage[T] = diff --git a/actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala b/actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala index b776be1f08..0c4f3905a6 100644 --- a/actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala +++ b/actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala @@ -24,6 +24,8 @@ import pekko.actor.{ ActorSelection, ClassicActorSystemProvider, Scheduler } import pekko.util.FutureConverters._ import pekko.util.JavaDurationConverters._ +import scala.annotation.nowarn + /** * Java API: for Pekko patterns such as `ask`, `pipe` and others which work with [[java.util.concurrent.CompletionStage]]. */ @@ -471,6 +473,8 @@ object Patterns { * if the provided value is not completed within the specified duration. * @since 1.2.0 */ + @deprecated("Use `CompletableFuture#orTimeout instead.", "Pekko 2.0.0") + @nowarn("msg=deprecated") def timeout[T]( duration: java.time.Duration, scheduler: Scheduler,