You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ArmeriaCatsBackend can be created with apply and then closeFactory will be true, but if it is created with usingClient or usingDefaultClient then closeFactory isfalse.
I don't know how to interpret it and what was the motivation behind it.
What I wanted to do is to create a method that would return SttpBackend with all the needed decorations of WebClient, but it's only possible to do it with usingClient which has closeFactory set to false.
And there's currently no workaround for it, because both constructor and apply method are private
I think the assumption is that if you are managing the WebClient instance yourself, you are also responsible for closing it. It's the same across other backends (not only Armeria-based) as far as I'm aware.
A work-around might be to create a backend wrapper which additionally does the necessary cleanup as part of its close(), and otherwise delegates all other method calls.
You can also propose a PR which adds a variant of these methods with the closeFactory flag - to this, and other backends?
apply(...): the backend creates the client, and closes it on close().
usingClient(client): you own the client. The backend never closes it.
resourceUsingClient(client) / scopedUsingClient(client): you hand the client over. It's closed when the resource is released.
So instead of adding a closeFactory flag, you can use ArmeriaCatsBackend.resourceUsingClient(client). It already closes the client's ClientFactory on release.
#2978 fills the gaps where this variant was missing: Armeria monix and zio1, OkHttp monix. It also makes HttpClientZioBackend.layerUsingClient close the client, like scopedUsingClient does.
Activity
adamw commentedon Aug 11, 2025
I think the assumption is that if you are managing the
WebClientinstance yourself, you are also responsible for closing it. It's the same across other backends (not only Armeria-based) as far as I'm aware.A work-around might be to create a backend wrapper which additionally does the necessary cleanup as part of its
close(), and otherwise delegates all other method calls.You can also propose a PR which adds a variant of these methods with the
closeFactoryflag - to this, and other backends?adamw commentedon Sep 25, 2026
All backends follow the same rule:
apply(...): the backend creates the client, and closes it onclose().usingClient(client): you own the client. The backend never closes it.resourceUsingClient(client)/scopedUsingClient(client): you hand the client over. It's closed when the resource is released.So instead of adding a
closeFactoryflag, you can useArmeriaCatsBackend.resourceUsingClient(client). It already closes the client'sClientFactoryon release.#2978 fills the gaps where this variant was missing: Armeria monix and zio1, OkHttp monix. It also makes
HttpClientZioBackend.layerUsingClientclose the client, likescopedUsingClientdoes.Add missing resource variants that close a user-provided client (soft…