Skip to content

Follow-up to max-connection-age: infinite grace test, docs, and FOREVER round-trip in Java setters - #1323

Merged
pjfanning merged 2 commits into
apache:mainfrom
pjfanning:max-connection-age-followup
Oct 3, 2026
Merged

pjfanning merged 2 commits into
apache:mainfrom
pjfanning:max-connection-age-followup

Conversation

@pjfanning

@pjfanning pjfanning commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Motivation

Addresses the points in #1316 (comment), including the suggested follow-up for the other Java setters that have the same FOREVER round-trip problem as withMaxConnectionAge.

Modification

  • reference.conf: the max-connection-age comment now also states the converse case, that a later terminate with an earlier deadline shortens a drain started by the age (also when max-connection-age-grace is infinite). This mirrors http2.md.
  • Http2ServerSpec: new test for max-connection-age-grace = infinite followed by a later terminate(10.millis).
  • Http2ServerSpec: wider timing margins. The age test now uses a 1s age with expectNoBytes(700.millis) (was 500ms / 400ms). The "not shorten" test now uses terminate(2.seconds) (was 1s).
  • Java setters whose getter returns ChronoUnit.FOREVER.getDuration for an infinite value now convert with JavaDurationConverter.toScala. Previously they used toScala, which throws IllegalArgumentException on that value. The affected setters are:
    • ClientConnectionSettings.withIdleTimeout
    • ConnectionPoolSettings.withIdleTimeout, withKeepAliveTimeout, withMaxConnectionLifetime, withResponseEntitySubscriptionTimeout
    • WebSocketSettings.withPeriodicKeepAliveMaxIdle

Result

  • The docs and tests cover both directions of the age/terminate interaction.
  • The timing-sensitive tests have more headroom on CI.
  • Infinite durations round-trip through the Java settings API. Before this change, withKeepAliveTimeout(getKeepAliveTimeout) threw on the default settings.

Tests

  • sbt "http2-tests/testOnly org.apache.pekko.http.impl.engine.http2.Http2ServerSpec -- -z max-connection-age": 7 tests pass
  • sbt "http-core/testOnly org.apache.pekko.http.scaladsl.settings.*": 27 tests pass. The 3 new round-trip tests fail without the fix (IllegalArgumentException: Java duration PT2562047788015215H30M7.999999999S cannot be expressed as a Scala duration)
  • sbt "http-core/mimaReportBinaryIssues": clean
  • scalafmt run on the changed Scala files

References

Refs #1316

🤖 Generated with Claude Code

…ace with a later terminate

Motivation:
Review of apache#1316 noted that reference.conf only documents one direction of
the interaction between max-connection-age and a server binding termination,
that the combination of max-connection-age-grace = infinite with a later
terminate was not tested, and that some new tests had tight timing margins.

Modification:
- reference.conf: state that a later terminate with an earlier deadline
  shortens a drain started by the age, also with an infinite grace period,
  mirroring http2.md.
- Http2ServerSpec: add a test for max-connection-age-grace = infinite
  followed by terminate(10.millis).
- Http2ServerSpec: widen timing margins (age 1s vs expectNoBytes(700ms),
  terminate(2s) vs expectNoBytes(700ms)).

Result:
The documented and tested behaviour covers both directions, and the timing
sensitive tests have more headroom on loaded CI machines.

Tests:
- sbt "http2-tests/testOnly ...Http2ServerSpec -- -z max-connection-age": 7 tests pass
- scalafmt on the changed spec

References:
Refs apache#1316
…n setters

Motivation:
Getters such as ConnectionPoolSettings.getKeepAliveTimeout return
ChronoUnit.FOREVER.getDuration for an infinite value, but the matching Java
setters converted with toScala, which throws IllegalArgumentException for
that value. Passing a getter's result back to its setter failed on the
default settings of keep-alive-timeout, max-connection-lifetime and
periodic-keep-alive-max-idle.

Modification:
Use JavaDurationConverter.toScala, the inverse of the toJava used by the
getters, in the Java setters of ClientConnectionSettings.idleTimeout,
ConnectionPoolSettings idleTimeout, keepAliveTimeout, maxConnectionLifetime
and responseEntitySubscriptionTimeout, and
WebSocketSettings.periodicKeepAliveMaxIdle.

Result:
Infinite durations round-trip through the Java API.

Tests:
- sbt "http-core/testOnly org.apache.pekko.http.scaladsl.settings.*": 27 pass;
  the 3 new round-trip tests fail without the fix
- sbt "http-core/mimaReportBinaryIssues": clean

References:
Refs apache#1316
@pjfanning pjfanning changed the title Follow-up to max-connection-age: document and test infinite grace with a later terminate Follow-up to max-connection-age: infinite grace test, docs, and FOREVER round-trip in Java setters Oct 2, 2026
@pjfanning
pjfanning merged commit 9c63776 into apache:main Oct 3, 2026
6 checks passed
@pjfanning
pjfanning deleted the max-connection-age-followup branch October 3, 2026 10:32
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