RFR: 8340182: Java HttpClient does not follow default retry limit of 3 retries

Darragh Clarke dclarke at openjdk.org
Wed Jun 4 13:16:18 UTC 2025


On Wed, 28 May 2025 12:04:31 GMT, Mikhail Yankelevich <myankelevich at openjdk.org> wrote:

>> The AuthenticationFilter did not respect the default retry limit of 3 retries in case of invalid credentials supplied.
>> 
>> This PR helps to resolve the bug and tests it with default and updated retry limit set via `jdk.httpclient.auth.retrylimit=1`.
>> 
>> The test is green with tiers 1, 2, 3 and the test is stable.
>
> test/jdk/java/net/httpclient/HttpClientRetryLimitTest.java line 52:
> 
>> 50: 
>> 51:     private static final int DEFAULT_RETRY_LIMIT = 3;
>> 52:     private final int retryLimit = Integer.getInteger("jdk.httpclient.auth.retrylimit", DEFAULT_RETRY_LIMIT);
> 
> Nit: This feels a bit confusing to me when reading it the first time, why not have a retry limit of 1 or 0 as a default and then specify if you want more retries in `@test`?
> I think it might be a bit easier to read, but if you want to keep it, it's fine with me.

This line is grabbing the value of the `jdk.httpclient.auth.retrylimit` system property, and if it hasn't been set then it defaults to 3. This is based on [AuthenticationFilter.java](https://github.com/openjdk/jdk/blob/e89aa7c712be8e576b640a123da52e7f4f5f9391/src/java.net.http/share/classes/jdk/internal/net/http/AuthenticationFilter.java#L57)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25490#discussion_r2112017438


More information about the net-dev mailing list