You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/11 11:59:25 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #8670: [hotfix][utils] Replace implemented FutureUtils#toJava with lib method

tillrohrmann commented on a change in pull request #8670: [hotfix][utils] Replace implemented FutureUtils#toJava with lib method
URL: https://github.com/apache/flink/pull/8670#discussion_r292416759
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
 ##########
 @@ -807,20 +805,8 @@ public static Time toTime(FiniteDuration finiteDuration) {
 	 * @return Java 8 CompletableFuture
 	 */
 	public static <T, U extends T> CompletableFuture<T> toJava(Future<U> scalaFuture) {
-		final CompletableFuture<T> result = new CompletableFuture<>();
-
-		scalaFuture.onComplete(new OnComplete<U>() {
-			@Override
-			public void onComplete(Throwable failure, U success) {
-				if (failure != null) {
-					result.completeExceptionally(failure);
-				} else {
-					result.complete(success);
-				}
-			}
-		}, Executors.directExecutionContext());
-
-		return result;
+		//noinspection unchecked
+		return scala.compat.java8.FutureConverters.toJava((Future<T>) scalaFuture).toCompletableFuture();
 
 Review comment:
   Where does this dependency come from? I fear that this is only a transitive dependency on which we should not directly depend.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services