Skip to content

Commit e162781

Browse files
authored
chore: Deprecate more methods in Futures (#2048)
1 parent 3b76767 commit e162781

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

actor/src/main/scala/org/apache/pekko/dispatch/Future.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ object Futures {
154154
/**
155155
* Creates an already completed CompletionStage with the specified exception
156156
*/
157+
@deprecated("Use `CompletableFuture.failedStage` instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
157158
def failedCompletionStage[T](ex: Throwable): CompletionStage[T] = {
158159
val f = CompletableFuture.completedFuture[T](null.asInstanceOf[T])
159160
f.obtrudeException(ex)
@@ -274,6 +275,7 @@ object japi {
274275
* Java API
275276
*/
276277
@nowarn("msg=deprecated")
278+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
277279
abstract class OnSuccess[-T] extends japi.CallbackBridge[T] {
278280
protected final override def internal(result: T) = onSuccess(result)
279281

@@ -292,6 +294,7 @@ abstract class OnSuccess[-T] extends japi.CallbackBridge[T] {
292294
* Java API
293295
*/
294296
@nowarn("msg=deprecated")
297+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
295298
abstract class OnFailure extends japi.CallbackBridge[Throwable] {
296299
protected final override def internal(failure: Throwable) = onFailure(failure)
297300

@@ -310,6 +313,7 @@ abstract class OnFailure extends japi.CallbackBridge[Throwable] {
310313
* Java API
311314
*/
312315
@nowarn("msg=deprecated")
316+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
313317
abstract class OnComplete[-T] extends japi.CallbackBridge[Try[T]] {
314318
protected final override def internal(value: Try[T]): Unit = value match {
315319
case Failure(t) => onComplete(t, null.asInstanceOf[T])
@@ -333,6 +337,7 @@ abstract class OnComplete[-T] extends japi.CallbackBridge[Try[T]] {
333337
* Java API
334338
*/
335339
@nowarn("msg=deprecated")
340+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
336341
abstract class Recover[+T] extends japi.RecoverBridge[T] {
337342
protected final override def internal(result: Throwable): T = recover(result)
338343

@@ -373,6 +378,7 @@ abstract class Recover[+T] extends japi.RecoverBridge[T] {
373378
* thus Java users should prefer `Future.map`, translating non-matching values
374379
* to failure cases.
375380
*/
381+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
376382
object Filter {
377383
@nowarn("msg=deprecated")
378384
def filterOf[T](f: pekko.japi.Function[T, java.lang.Boolean]): (T => Boolean) =
@@ -388,6 +394,7 @@ object Filter {
388394
* Java API
389395
*/
390396
@nowarn("msg=deprecated")
397+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
391398
abstract class Foreach[-T] extends japi.UnitFunctionBridge[T] {
392399
override final def internal(t: T): Unit = each(t)
393400

@@ -410,6 +417,7 @@ abstract class Foreach[-T] extends japi.UnitFunctionBridge[T] {
410417
*
411418
* Java API
412419
*/
420+
@deprecated("Use Java's CompletableFuture instead, will be removed in Pekko 2.0.0", "Pekko 1.2.0")
413421
abstract class Mapper[-T, +R] extends scala.runtime.AbstractFunction1[T, R] {
414422

415423
/**

actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
package org.apache.pekko.pattern
1515

1616
import java.util.concurrent.{ CompletableFuture, CompletionStage, TimeoutException }
17-
1817
import scala.concurrent.{ ExecutionContext, Future, Promise }
1918
import scala.concurrent.duration.FiniteDuration
2019
import scala.util.control.NonFatal
21-
2220
import org.apache.pekko
2321
import pekko.actor._
2422
import pekko.dispatch.Futures
2523

24+
import scala.annotation.nowarn
25+
2626
trait FutureTimeoutSupport {
2727

2828
/**
@@ -66,6 +66,7 @@ trait FutureTimeoutSupport {
6666
* Returns a [[java.util.concurrent.CompletionStage]] that will be completed with the success or failure of the provided value
6767
* after the specified duration.
6868
*/
69+
@nowarn("msg=deprecated")
6970
def afterCompletionStage[T](duration: FiniteDuration, using: Scheduler)(value: => CompletionStage[T])(
7071
implicit ec: ExecutionContext): CompletionStage[T] =
7172
if (duration.isFinite && duration.length < 1) {
@@ -124,6 +125,7 @@ trait FutureTimeoutSupport {
124125
* if the provided value is not completed within the specified duration.
125126
* @since 1.2.0
126127
*/
128+
@nowarn("msg=deprecated")
127129
def timeoutCompletionStage[T](duration: FiniteDuration, using: Scheduler)(value: => CompletionStage[T])(
128130
implicit ec: ExecutionContext): CompletionStage[T] = {
129131
val stage: CompletionStage[T] =

0 commit comments

Comments
 (0)