You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2025/12/21 18:35:11 UTC
(maven-plugin-tools) branch http5 created (now a072190a)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch http5
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
at a072190a Migrate to ApacheHttpClient 5.x
This branch includes the following new commits:
new a072190a Migrate to ApacheHttpClient 5.x
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven-plugin-tools) 01/01: Migrate to ApacheHttpClient 5.x
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch http5
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit a072190a99ae9d07a28163338fb693951efeccb9
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Nov 8 16:15:08 2025 +0100
Migrate to ApacheHttpClient 5.x
Co-authored-by: Moderne <te...@moderne.io>
---
maven-plugin-tools-api/pom.xml | 11 +---
.../maven/tools/plugin/javadoc/JavadocSite.java | 69 +++++++++++-----------
2 files changed, 38 insertions(+), 42 deletions(-)
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index b32f83da..2171a3b8 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -88,14 +88,9 @@
</dependency>
<!-- for retrieving package-list or element-list of existing javadoc sites -->
<dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.5.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.4.16</version>
+ <groupId>org.apache.httpcomponents.client5</groupId>
+ <artifactId>httpclient5</artifactId>
+ <version>5.6</version>
</dependency>
<!-- wagon for proxy related classes -->
<dependency>
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
index 36670126..a01c8840 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
@@ -39,32 +39,33 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.regex.Pattern;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.message.BasicHeader;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsStore;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.cookie.StandardCookieSpec;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.apache.maven.tools.plugin.javadoc.FullyQualifiedJavadocReference.MemberType;
@@ -472,10 +473,10 @@ class JavadocSite {
builder.setConnectionManager(new PoolingHttpClientConnectionManager(csfRegistry));
builder.setDefaultRequestConfig(RequestConfig.custom()
- .setSocketTimeout(DEFAULT_TIMEOUT)
- .setConnectTimeout(DEFAULT_TIMEOUT)
+ .setResponseTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
+ .setConnectTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
.setCircularRedirectsAllowed(true)
- .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
+ .setCookieSpec(StandardCookieSpec.IGNORE)
.build());
// Some web servers don't allow the default user-agent sent by httpClient
@@ -496,11 +497,11 @@ class JavadocSite {
builder.setProxy(proxy);
if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
- Credentials credentials =
- new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
+ Credentials credentials = new UsernamePasswordCredentials(
+ activeProxy.getUsername(), activeProxy.getPassword().toCharArray());
- CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
- credentialsProvider.setCredentials(AuthScope.ANY, credentials);
+ CredentialsStore credentialsProvider = new BasicCredentialsProvider();
+ credentialsProvider.setCredentials(new AuthScope(null, -1), credentials);
builder.setDefaultCredentialsProvider(credentialsProvider);
}
}
@@ -520,7 +521,7 @@ class JavadocSite {
final HttpGet httpMethod = new HttpGet(url.toString());
- HttpResponse response;
+ ClassicHttpResponse response;
HttpClientContext httpContext = HttpClientContext.create();
try {
response = httpClient.execute(httpMethod, httpContext);
@@ -529,13 +530,13 @@ class JavadocSite {
response = httpClient.execute(httpMethod, httpContext);
}
- int status = response.getStatusLine().getStatusCode();
+ int status = response.getCode();
if (status != HttpStatus.SC_OK) {
throw new FileNotFoundException(
"Unexpected HTTP status code " + status + " getting resource " + url.toExternalForm() + ".");
} else {
int pos = url.getPath().lastIndexOf('/');
- List<URI> redirects = httpContext.getRedirectLocations();
+ List<URI> redirects = httpContext.getRedirectLocations().getAll();
if (pos >= 0 && isNotEmpty(redirects)) {
URI location = redirects.get(redirects.size() - 1);
String suffix = url.getPath().substring(pos);
@@ -555,7 +556,7 @@ class JavadocSite {
super.close();
if (httpMethod != null) {
- httpMethod.releaseConnection();
+ httpMethod.reset();
}
if (httpClient != null) {
httpClient.close();