Conversation
Motivation: Java users should not need to touch Scala Future at all. Standard java.util.concurrent.CompletableFuture and CompletionStages provide equivalent functionality. Modification: - Mark Futures object and all its methods as deprecated (since 2.0.0) - Add CompletionStages.fromScala as replacement for Futures.asJava - Replace internal Futures.failedCompletionStage usage in CompletionStages.reduce with CompletableFuture.failedFuture - Migrate Java tests to use CompletableFuture/CompletionStages directly Result: Clear deprecation path for Java users toward standard Java APIs. Tests: - sbt "actor-tests/Test/testOnly org.apache.pekko.dispatch.JavaFutureTests org.apache.pekko.dispatch.CompletionStagesTests org.apache.pekko.pattern.PatternsTest" / 44 passed References: Fixes apache#1417
Motivation: failedStage returns CompletionStage directly, which is the correct replacement for failedCompletionStage and matches the return types in CompletionStages.reduce and the test callables. Modification: - Fix deprecation message on failedCompletionStage - Use failedStage in CompletionStages.reduce - Use failedStage in Java test replacements Result: Consistent use of the CompletionStage-typed API. Tests: - sbt "actor-tests/Test/testOnly org.apache.pekko.dispatch.JavaFutureTests org.apache.pekko.dispatch.CompletionStagesTests org.apache.pekko.pattern.PatternsTest" / 44 passed References: Fixes apache#1417
Motivation: Users should be directed to the new CompletionStages.fromScala method rather than the low-level scala.jdk.FutureConverters. Modification: Update deprecation message on Futures.asJava. Result: Consistent migration path through CompletionStages API. Tests: - Not run - message-only change References: Fixes apache#1417
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Java users should not need to touch Scala
Futureat all. Standardjava.util.concurrent.CompletableFutureandCompletionStagesprovide equivalent functionality. TheFuturesclass was introduced when Akka still supported Java versions before Java 8.Modification
Futuresobject and all its methods as@deprecated(since = "2.0.0")CompletionStages.fromScalaas replacement forFutures.asJavaFutures.failedCompletionStageusage inCompletionStages.reducewithCompletableFuture.failedFutureCompletableFuture/CompletionStagesdirectlyResult
Clear deprecation path for Java users toward standard Java APIs. Each deprecated method points to its specific replacement:
Futures.asJava→scala.jdk.FutureConverters/CompletionStages.fromScalaFutures.future→CompletableFuture.supplyAsyncFutures.promise→new CompletableFutureFutures.failed→CompletableFuture.failedFutureFutures.successful→CompletableFuture.completedFutureFutures.failedCompletionStage→CompletableFuture.failedFutureTests
sbt "actor-tests/Test/testOnly org.apache.pekko.dispatch.JavaFutureTests org.apache.pekko.dispatch.CompletionStagesTests org.apache.pekko.pattern.PatternsTest"— 44 passedReferences
Fixes #1417