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
{{ message }}
Repository navigation
[IMPROVEMENT] withRetries should not affect other calls #75
As the current implementation stands, calling withRetries on the Vault object modifies the retry logic for all subsequent calls to Vault, unless they specifically override it using withRetries in their own call.
I'd like it if withRetries would only affect the call being made and not any other ones that follow after.
It also is a bit of a code smell that the VaultConfig final object gets manipulated using the withRetries call. I propose withRetries returns a new RetryingVault (or similar) interface, and move that holds the parameters for a retry in it's own implementation, and passes a copy of Vault Config extended with the retry parameters to the Logical, Auth, and other dsl classes that would rely on it.
Thanks for the report. The next release lets you set retries for a single call without changing the
configuration, through a new method rather than by changing withRetries().
retrying() returns a newVault whose operations use those retries. The original vault
and its VaultConfig are left unchanged, so later calls on vault are not affected. The retry
settings are held in a new immutable RetryPolicy and passed to Logical, Auth, Sys and the
other operation classes, including the ones they create (e.g. sys().leases()).
would still compile, but would silently stop retrying. That would only show up during a Vault
outage, which is exactly when retries matter. So withRetries() keeps its current behaviour and is
now @Deprecated, with Javadoc pointing to retrying() and VaultConfig.retries().
Why the configuration is shared rather than copied
The issue suggested passing a copy of VaultConfig with the retry settings. Instead, the Vault
returned by retrying() shares the original configuration and keeps the retries separately. A copy
would miss later changes, such as a renewed token, and its HTTP client and SslConfig would need
special handling. Sharing the configuration keeps it unchanged while still applying those later
changes.
What's left
Removing withRetries(), or making it return a new instance like retrying(), is a breaking
change, so it is planned for the next major release and tracked in #.
Closing this, since retries can now be limited to some calls without changing the configuration.
Activity
henryx commentedon Oct 15, 2026
Thanks for the report. The next release lets you set retries for a single call without changing the
configuration, through a new method rather than by changing
withRetries().Retries for some calls:
Vault.retrying()retrying()returns a newVaultwhose operations use those retries. The originalvaultand its
VaultConfigare left unchanged, so later calls onvaultare not affected. The retrysettings are held in a new immutable
RetryPolicyand passed toLogical,Auth,Sysand theother operation classes, including the ones they create (e.g.
sys().leases()).Retries for every call:
VaultConfig.retries()Both methods reject negative values with
IllegalArgumentException.Why
withRetries()is deprecated rather than changedChanging what
withRetries()does would break existing code without any compile error. Code likethis:
would still compile, but would silently stop retrying. That would only show up during a Vault
outage, which is exactly when retries matter. So
withRetries()keeps its current behaviour and isnow
@Deprecated, with Javadoc pointing toretrying()andVaultConfig.retries().Why the configuration is shared rather than copied
The issue suggested passing a copy of
VaultConfigwith the retry settings. Instead, theVaultreturned by
retrying()shares the original configuration and keeps the retries separately. A copywould miss later changes, such as a renewed token, and its HTTP client and
SslConfigwould needspecial handling. Sharing the configuration keeps it unchanged while still applying those later
changes.
What's left
Removing
withRetries(), or making it return a new instance likeretrying(), is a breakingchange, so it is planned for the next major release and tracked in #.
Closing this, since retries can now be limited to some calls without changing the configuration.