Compare commits

...

2 Commits

Author SHA1 Message Date
Prateek Nima
8803830b39 update copyright 2025-06-12 18:37:35 +01:00
Prateek Nima
9e8f29ee3a apply review feedback and update java docs to clarify authentication retry behaviour 2025-06-12 16:23:30 +01:00
3 changed files with 6 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -328,7 +328,7 @@ class AuthenticationFilter implements HeaderFilter {
req = HttpRequestImpl.newInstanceForAuthentication(req);
addBasicCredentials(req, proxy, pw, isUTF8);
return req;
} else if (au.retries >= retry_limit) {
} else if (au.retries > retry_limit) {
throw new IOException("too many authentication attempts. Limit: " +
retry_limit);
} else {

View File

@ -156,7 +156,8 @@
* </li>
* <li><p><b>{@systemProperty jdk.httpclient.auth.retrylimit}</b> (default: 3)<br>
* The number of attempts the Basic authentication filter will attempt to retry a failed
* authentication.
* authentication. The number of authentication attempts is always one greater than the
* retry limit, as the initial request does not count toward the retries.
* </li>
* <li><p><b>{@systemProperty jdk.httpclient.sendBufferSize}</b> (default: operating system
* default)<br>The HTTP client {@linkplain java.nio.channels.SocketChannel socket}

View File

@ -4,9 +4,7 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@ -129,11 +127,7 @@ class HttpClientAuthRetryLimitTest implements HttpServerAdapters {
request, HttpResponse.BodyHandlers.discarding()));
assertEquals("too many authentication attempts. Limit: " + RETRY_LIMIT, exception.getMessage());
int totalRequestCount = requestCount.get();
if (RETRY_LIMIT > 0){
assertEquals(RETRY_LIMIT, totalRequestCount);
} else {
assertEquals(0, totalRequestCount - 1);
}
assertEquals(totalRequestCount, Math.max(RETRY_LIMIT, 0) + 1);
}
}
}