Skip to content

Deprecate org.apache.pekko.dispatch.Futures - #3374

Closed
He-Pin wants to merge 3 commits into
apache:mainfrom
He-Pin:deprecate-dispatch-futures
Closed

He-Pin wants to merge 3 commits into
apache:mainfrom
He-Pin:deprecate-dispatch-futures

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 22, 2026

Copy link
Copy Markdown
Member

Motivation

Java users should not need to touch Scala Future at all. Standard java.util.concurrent.CompletableFuture and CompletionStages provide equivalent functionality. The Futures class was introduced when Akka still supported Java versions before Java 8.

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. Each deprecated method points to its specific replacement:

  • Futures.asJava → scala.jdk.FutureConverters / CompletionStages.fromScala
  • Futures.future → CompletableFuture.supplyAsync
  • Futures.promise → new CompletableFuture
  • Futures.failed → CompletableFuture.failedFuture
  • Futures.successful → CompletableFuture.completedFuture
  • Futures.failedCompletionStage → CompletableFuture.failedFuture

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 #1417

He-Pin added 3 commits July 22, 2026 20:24
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
@He-Pin He-Pin closed this Jul 22, 2026
@He-Pin
He-Pin deleted the deprecate-dispatch-futures branch July 22, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate org.apache.pekko.dispatch.Futures

1 participant