#2729 - Removing uses of Future.either in favor of firstCompletedOf
This commit is contained in:
parent
6a348e3c76
commit
f386c4136f
2 changed files with 3 additions and 3 deletions
|
|
@ -43,10 +43,10 @@ import scala.concurrent.ExecutionContext$;
|
||||||
|
|
||||||
//#imports8
|
//#imports8
|
||||||
import static akka.pattern.Patterns.after;
|
import static akka.pattern.Patterns.after;
|
||||||
|
import java.util.Arrays;
|
||||||
//#imports8
|
//#imports8
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
@ -564,7 +564,7 @@ public class FutureDocTestBase {
|
||||||
return "foo";
|
return "foo";
|
||||||
}
|
}
|
||||||
}, ec);
|
}, ec);
|
||||||
Future<String> result = future.either(delayed);
|
Future<String> result = Futures.firstCompletedOf(Arrays.asList(future, delayed), ec);
|
||||||
//#after
|
//#after
|
||||||
Await.result(result, Duration.create(2, SECONDS));
|
Await.result(result, Duration.create(2, SECONDS));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,7 @@ class FutureDocSpec extends AkkaSpec {
|
||||||
val delayed = after(200 millis, using = system.scheduler)(Future.failed(
|
val delayed = after(200 millis, using = system.scheduler)(Future.failed(
|
||||||
new IllegalStateException("OHNOES")))
|
new IllegalStateException("OHNOES")))
|
||||||
val future = Future { Thread.sleep(1000); "foo" }
|
val future = Future { Thread.sleep(1000); "foo" }
|
||||||
val result = future either delayed
|
val result = Future firstCompletedOf Seq(future, delayed)
|
||||||
//#after
|
//#after
|
||||||
intercept[IllegalStateException] { Await.result(result, 2 second) }
|
intercept[IllegalStateException] { Await.result(result, 2 second) }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue