Skip to content

feat: add closeFactory/closeClient parameter to usingClient/usingDefaultClient - #2959

Open
mmustafasenoglu wants to merge 1 commit into
softwaremill:masterfrom
mmustafasenoglu:feat/closefactory-param
Open

feat: add closeFactory/closeClient parameter to usingClient/usingDefaultClient#2959
mmustafasenoglu wants to merge 1 commit into
softwaremill:masterfrom
mmustafasenoglu:feat/closefactory-param

Conversation

@mmustafasenoglu

Copy link
Copy Markdown
Contributor

Summary

Adds an optional closeFactory/closeClient: Boolean = false parameter to all public usingClient and usingDefaultClient factory methods across Armeria (9 backends) and OkHttp (2 backends).

Motivation

The usingClient and usingDefaultClient methods hardcoded closeFactory to false, giving users no way to have the backend close a user-provided client on backend.close(). This was reported in #2628.

Changes

Armeria backends (9 files):

  • ArmeriaCatsBackend (CE3 + CE2): added closeFactory: Boolean = false to usingClient, usingDefaultClient
  • ArmeriaFutureBackend: same
  • ArmeriaFs2Backend (CE3 + CE2): same
  • ArmeriaZioBackend (ZIO 2 + ZIO 1): same (including usingClient with runtime overload)
  • ArmeriaMonixBackend: same
  • ArmeriaScalazBackend: same

OkHttp backends (2 files):

  • OkHttpSyncBackend: added closeClient: Boolean = false to usingClient
  • OkHttpFutureBackend: same

Backward Compatibility

All changes use default parameter values (false), so existing code continues to work without modification. MiMa is currently disabled for these subprojects.

Testing

  • Existing tests pass (default behavior unchanged)
  • New parameter allows users to control client lifecycle

Closes #2628

…ultClient

The usingClient and usingDefaultClient factory methods on Armeria and
OkHttp backends hardcoded closeFactory/closeClient to false, giving
users no way to have the backend close a user-provided client.

This adds an optional closeFactory/closeClient: Boolean = false parameter
to all public factory methods, allowing users to control whether the
backend should close the underlying client on backend.close().

Armeria backends (9 files):
- ArmeriaCatsBackend (CE3 + CE2)
- ArmeriaFutureBackend
- ArmeriaFs2Backend (CE3 + CE2)
- ArmeriaZioBackend (ZIO 2 + ZIO 1)
- ArmeriaMonixBackend
- ArmeriaScalazBackend

OkHttp backends (2 files):
- OkHttpSyncBackend
- OkHttpFutureBackend

Closes softwaremill#2628
Copilot AI review requested due to automatic review settings August 2, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Confusing ArmeriaCatsBackend initialization

2 participants