use CompletableFuture#failedStage (#2013)
This commit is contained in:
parent
1b8de23911
commit
7d5e5daa70
2 changed files with 3 additions and 3 deletions
|
|
@ -137,6 +137,7 @@ object Futures {
|
|||
/**
|
||||
* Creates an already completed CompletionStage with the specified exception
|
||||
*/
|
||||
@deprecated("Use `CompletableFuture#failedStage` instead.", since = "2.0.0")
|
||||
def failedCompletionStage[T](ex: Throwable): CompletionStage[T] = {
|
||||
val f = CompletableFuture.completedFuture[T](null.asInstanceOf[T])
|
||||
f.obtrudeException(ex)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import scala.util.control.NonFatal
|
|||
|
||||
import org.apache.pekko
|
||||
import pekko.actor._
|
||||
import pekko.dispatch.Futures
|
||||
|
||||
trait FutureTimeoutSupport {
|
||||
|
||||
|
|
@ -70,7 +69,7 @@ trait FutureTimeoutSupport {
|
|||
implicit ec: ExecutionContext): CompletionStage[T] =
|
||||
if (duration.isFinite && duration.length < 1) {
|
||||
try value
|
||||
catch { case NonFatal(t) => Futures.failedCompletionStage(t) }
|
||||
catch { case NonFatal(t) => CompletableFuture.failedStage(t) }
|
||||
} else {
|
||||
val p = new CompletableFuture[T]
|
||||
using.scheduleOnce(duration) {
|
||||
|
|
@ -129,7 +128,7 @@ trait FutureTimeoutSupport {
|
|||
val stage: CompletionStage[T] =
|
||||
try value
|
||||
catch {
|
||||
case NonFatal(t) => Futures.failedCompletionStage(t)
|
||||
case NonFatal(t) => CompletableFuture.failedStage(t)
|
||||
}
|
||||
if (stage.toCompletableFuture.isDone) {
|
||||
stage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue