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

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


The following commit(s) were added to refs/heads/1.2.x by this push:
     new e162781d5d chore: Deprecate more methods in Futures (#2048)
e162781d5d is described below

commit e162781d5d72d1af0239e9c04aabf593d35d7e53
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Aug 23 16:43:53 2025 +0800

    chore: Deprecate more methods in Futures (#2048)
---
 actor/src/main/scala/org/apache/pekko/dispatch/Future.scala       | 8 ++++++++
 .../scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala     | 6 ++++--
 2 files changed, 12 insertions(+), 2 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 d54b30a321..337ec60b8d 100644
--- a/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala
+++ b/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala
@@ -154,6 +154,7 @@ object Futures {
   /**
    * Creates an already completed CompletionStage with the specified exception
    */
+  @deprecated("Use `CompletableFuture.failedStage` instead, will be removed in 
Pekko 2.0.0", "Pekko 1.2.0")
   def failedCompletionStage[T](ex: Throwable): CompletionStage[T] = {
     val f = CompletableFuture.completedFuture[T](null.asInstanceOf[T])
     f.obtrudeException(ex)
@@ -274,6 +275,7 @@ object japi {
  * Java API
  */
 @nowarn("msg=deprecated")
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class OnSuccess[-T] extends japi.CallbackBridge[T] {
   protected final override def internal(result: T) = onSuccess(result)
 
@@ -292,6 +294,7 @@ abstract class OnSuccess[-T] extends japi.CallbackBridge[T] 
{
  * Java API
  */
 @nowarn("msg=deprecated")
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class OnFailure extends japi.CallbackBridge[Throwable] {
   protected final override def internal(failure: Throwable) = 
onFailure(failure)
 
@@ -310,6 +313,7 @@ abstract class OnFailure extends 
japi.CallbackBridge[Throwable] {
  * Java API
  */
 @nowarn("msg=deprecated")
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class OnComplete[-T] extends japi.CallbackBridge[Try[T]] {
   protected final override def internal(value: Try[T]): Unit = value match {
     case Failure(t) => onComplete(t, null.asInstanceOf[T])
@@ -333,6 +337,7 @@ abstract class OnComplete[-T] extends 
japi.CallbackBridge[Try[T]] {
  * Java API
  */
 @nowarn("msg=deprecated")
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class Recover[+T] extends japi.RecoverBridge[T] {
   protected final override def internal(result: Throwable): T = recover(result)
 
@@ -373,6 +378,7 @@ abstract class Recover[+T] extends japi.RecoverBridge[T] {
  * thus Java users should prefer `Future.map`, translating non-matching values
  * to failure cases.
  */
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 object Filter {
   @nowarn("msg=deprecated")
   def filterOf[T](f: pekko.japi.Function[T, java.lang.Boolean]): (T => 
Boolean) =
@@ -388,6 +394,7 @@ object Filter {
  * Java API
  */
 @nowarn("msg=deprecated")
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class Foreach[-T] extends japi.UnitFunctionBridge[T] {
   override final def internal(t: T): Unit = each(t)
 
@@ -410,6 +417,7 @@ abstract class Foreach[-T] extends 
japi.UnitFunctionBridge[T] {
  *
  * Java API
  */
+@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 
2.0.0", "Pekko 1.2.0")
 abstract class Mapper[-T, +R] extends scala.runtime.AbstractFunction1[T, R] {
 
   /**
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 67b40a1187..7e04bc5396 100644
--- a/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala
+++ b/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala
@@ -14,15 +14,15 @@
 package org.apache.pekko.pattern
 
 import java.util.concurrent.{ CompletableFuture, CompletionStage, 
TimeoutException }
-
 import scala.concurrent.{ ExecutionContext, Future, Promise }
 import scala.concurrent.duration.FiniteDuration
 import scala.util.control.NonFatal
-
 import org.apache.pekko
 import pekko.actor._
 import pekko.dispatch.Futures
 
+import scala.annotation.nowarn
+
 trait FutureTimeoutSupport {
 
   /**
@@ -66,6 +66,7 @@ trait FutureTimeoutSupport {
    * Returns a [[java.util.concurrent.CompletionStage]] that will be completed 
with the success or failure of the provided value
    * after the specified duration.
    */
+  @nowarn("msg=deprecated")
   def afterCompletionStage[T](duration: FiniteDuration, using: 
Scheduler)(value: => CompletionStage[T])(
       implicit ec: ExecutionContext): CompletionStage[T] =
     if (duration.isFinite && duration.length < 1) {
@@ -124,6 +125,7 @@ trait FutureTimeoutSupport {
    * if the provided value is not completed within the specified duration.
    * @since 1.2.0
    */
+  @nowarn("msg=deprecated")
   def timeoutCompletionStage[T](duration: FiniteDuration, using: 
Scheduler)(value: => CompletionStage[T])(
       implicit ec: ExecutionContext): CompletionStage[T] = {
     val stage: CompletionStage[T] =


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

Reply via email to