Skip to content

Conversation

pjfanning
Copy link
Member

* 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
@pjfanning pjfanning added this to the 2.0.0 milestone Sep 17, 2025
@He-Pin He-Pin requested a review from Copilot September 17, 2025 17:39
Copy link

@Copilot Copilot AI left a 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._
Copy link
Preview

Copilot AI Sep 17, 2025

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.

Suggested change
import scala.jdk.DurationConverters._
import pekko.util.JavaDurationConverters._

Copilot uses AI. Check for mistakes.

Copy link
Member Author

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();
Copy link
Member

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

Copy link
Member Author

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.

@pjfanning pjfanning merged commit 340ea15 into apache:main Sep 17, 2025
6 checks passed
@pjfanning pjfanning deleted the duration-javadsl branch September 17, 2025 19:50
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.

2 participants