File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
main/scala/scala/concurrent/java8
test/java/scala/compat/java8 Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ object FuturesConvertersImpl {
7070 * @inheritdoc
7171 *
7272 * WARNING: completing the result of this method will not complete the underlying
73- * Scala Future or Promise.
73+ * Scala Future or Promise (ie, the one that that was passed to `toJava`.)
7474 */
7575 override def toCompletableFuture (): CompletableFuture [T ] = {
7676 this // TODO or maybe `thenApply(JF.identity())`
Original file line number Diff line number Diff line change @@ -363,4 +363,17 @@ public void testToJavaToCompletableFutureDoesNotMutateUnderlyingPromise() throws
363363 assertFalse (sf .isCompleted ());
364364 assertFalse (p .isCompleted ());
365365 }
366+
367+ @ Test
368+ public void testToJavaToCompletableFutureJavaCompleteCallledAfterScalaComplete () throws ExecutionException , InterruptedException {
369+ final Promise <String > p = promise ();
370+ Future <String > sf = p .future ();
371+ final CompletionStage <String > cs = toJava (sf );
372+ CompletableFuture <String > cf = cs .toCompletableFuture ();
373+ assertEquals ("notyet" , cf .getNow ("notyet" ));
374+ p .success ("scaladone" );
375+ assertEquals ("scaladone" , cf .get ());
376+ cf .complete ("javadone" );
377+ assertEquals ("scaladone" , cf .get ());
378+ }
366379}
You can’t perform that action at this time.
0 commit comments