chore: Deprecate Patterns.timeout method. (#2050)
This commit is contained in:
parent
5bf36c85d8
commit
629b7d74fe
3 changed files with 8 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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] =
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue