File tree 2 files changed +14
-1
lines changed
main/scala/scala/concurrent/java8
test/java/scala/compat/java8
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ object FuturesConvertersImpl {
70
70
* @inheritdoc
71
71
*
72
72
* 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`.)
74
74
*/
75
75
override def toCompletableFuture (): CompletableFuture [T ] = {
76
76
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
363
363
assertFalse (sf .isCompleted ());
364
364
assertFalse (p .isCompleted ());
365
365
}
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
+ }
366
379
}
You can’t perform that action at this time.
0 commit comments