This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 629b7d74fe chore: Deprecate Patterns.timeout method. (#2050)
629b7d74fe is described below

commit 629b7d74fe909eca1a019fe41f194603c9f36650
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Aug 23 18:21:21 2025 +0800

    chore: Deprecate Patterns.timeout method. (#2050)
---
 actor-tests/src/test/java/org/apache/pekko/pattern/PatternsTest.java  | 3 +++
 .../main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala    | 1 +
 actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala          | 4 ++++
 3 files changed, 8 insertions(+)

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<String> delayedStage =
@@ -501,6 +502,7 @@ public class PatternsTest extends JUnitSuite {
   }
 
   @Test
+  @SuppressWarnings("deprecation")
   public void testFailedCompletedStageWithTimeout() throws Exception {
     final CompletionStage<String> delayedStage =
         Patterns.timeout(
@@ -521,6 +523,7 @@ public class PatternsTest extends JUnitSuite {
   }
 
   @Test
+  @SuppressWarnings("deprecation")
   public void testCompletedWithTimeout() throws Exception {
     final CompletionStage<String> 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,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to