## Issue
Related to #5789
## Change
`ApacheHttpClient` builds the underlying Apache HttpClient 5 sync/async
clients from `HttpClients.custom()` / `HttpAsyncClients.custom()`, which
have `automaticRetriesDisabled = false` by default. As a result,
Apache's `DefaultHttpRequestRetryStrategy` transparently retries
requests (e.g. on connection failures and on HTTP `429`/`503`)
**underneath** LangChain4j's own retry logic. This has two consequences:
- `maxRetries=0` does not actually disable retries — Apache still
retries at the transport level.
- For any `maxRetries` value, retries are effectively stacked
(LangChain4j retries × Apache retries).
This PR makes LangChain4j the single source of truth for retry behavior:
when `ApacheHttpClient` creates the client builders itself, it now calls
`disableAutomaticRetries()` on both the sync and async
builders.
To avoid overriding an explicit user choice, this is only applied to the
**default (LangChain4j-created) builders**. If a user supplies their own
`httpClientBuilder`/`httpAsyncClientBuilder`, their retry
configuration is left untouched — they remain free to configure retries
as they wish (and can call `disableAutomaticRetries()` themselves if
they want LangChain4j to be the only retry layer).
**Note on behavior:** for users on the default builder who were (often
unknowingly) relying on Apache's implicit retries, those transport-level
retries are no longer performed; retries are now governed solely
by LangChain4j's `maxRetries`. No public API changes (verified with
`revapi:check`).
This mirrors the Spring-side fix for `SpringRestClient` in
langchain4j/langchain4j-spring#200.
### Tests
Added `ApacheHttpClientRetriesIT` (WireMock, always returns `503`),
covering both cases:
- default builder → exactly **1** request is made (no transport-level
retry);
- user-supplied builder with an explicit
`DefaultHttpRequestRetryStrategy(2, …)` → **3** requests are made (1
initial + 2 retries), i.e. the user's configuration is honored.
No new dependencies were added (WireMock is already a test dependency
across modules).
## General checklist
- [x] There are no breaking changes (API, behaviour)
- [x] I have added unit and/or integration tests for my change
- [x] The tests cover both positive and negative cases
- [x] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langch 1 new message (ctrl+End) ↓
ig" features)