-
Notifications
You must be signed in to change notification settings - Fork 48
Java duration in javadsl (#780) #784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pjfanning
commented
Sep 17, 2025
- Forward fit of Java duration in javadsl #780
- there is some follow up work
- switch to Scala DurationConverters #782
- Change Java DSL methods that return Scala Durations to return Java Durations #783
* allow java durations to be used in pekko-http javadsl * web socket settings * Update WebSocketSettings.scala * compile issue * more changes * mima * ClientConnectionSettings * ConnectionPoolSettings * javafmt * Update java-duration-support-javadsl.excludes * imports * Update CachingDirectivesExamplesTest.java * examples * update tests Update WSProbe.scala
http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for java.time.Duration
in the Java DSL APIs, supplementing existing methods that use scala.concurrent.duration.Duration
types. It enhances Java interoperability by providing overloaded methods that accept the standard Java 8 Duration
type while deprecating the Scala duration equivalents.
- Adds Java Duration support across timeout directives, settings classes, and test utilities
- Deprecates existing Scala Duration methods in favor of Java Duration equivalents
- Updates import statements to use more specific imports and Java duration converters
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
TimeoutDirectives.scala | Added Java Duration overloads for timeout methods and deprecated Scala versions |
BasicDirectives.scala | Added Java Duration support for entity extraction methods with deprecations |
Various settings classes | Added Java Duration support in connection, websocket, and cache settings |
Test files | Updated to use Java Duration types in examples and tests |
HttpServerBluePrint.scala | Enhanced timeout access interface with Java Duration support |
TimeoutAccess.java | Extended interface to support both Scala and Java Duration types |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor } | ||
import scala.concurrent.duration.FiniteDuration | ||
import scala.jdk.DurationConverters._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import scala.jdk.DurationConverters._
should be pekko.util.JavaDurationConverters._
to be consistent with other files in this PR that use the Pekko-specific duration converters.
import scala.jdk.DurationConverters._ | |
import pekko.util.JavaDurationConverters._ |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in 2.0.0, we are switching to scala.jdk converters
* before the previously set timeout has expired! | ||
*/ | ||
Duration getTimeout(); | ||
scala.concurrent.duration.Duration getTimeout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be deprecated or at least add some doc about that it will be Java duration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to break this API in a later commit. This is just a forward fit of #780. For traceability, I want to add those changes in one PR and do another PR with the 2.0.0 breaking changes.
This API method isn't changing in this PR, I just fully referenced scala.concurrent.duration.Duration to make it more obvious that that was class that was being returned.
In my follow up PR, I will change the return type to java.time.Duration.