Skip to content

Commit

Permalink
Issue eclipse-ee4j#4897 - Support for Apache HTTP Client 5.x
Browse files Browse the repository at this point in the history
Migration to HTTP Client 5 classic APIs

Signed-off-by: Steffen Nießing <[email protected]>
  • Loading branch information
zUniQueX committed Dec 26, 2021
1 parent b881a3d commit 22e4b7b
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 476 deletions.
4 changes: 2 additions & 2 deletions connectors/apache-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -28,6 +28,7 @@
* @author Paul Sandoz
* @author Pavel Bucek
* @author Arul Dhesiaseelan (aruld at acm.org)
* @author Steffen Nießing
*/
@PropertiesClass
public final class ApacheClientProperties {
Expand All @@ -37,7 +38,7 @@ public final class ApacheClientProperties {
* credentials from a user. Credentials needed for proxy authentication
* are stored here as well.
* <p/>
* The value MUST be an instance of {@link org.apache.http.client.CredentialsProvider}.
* The value MUST be an instance of {@link org.apache.hc.client5.http.auth.CredentialsProvider}.
* <p/>
* If the property is absent a default provider will be used.
* <p/>
Expand Down Expand Up @@ -74,14 +75,14 @@ public final class ApacheClientProperties {
public static final String PREEMPTIVE_BASIC_AUTHENTICATION = "jersey.config.apache.client.preemptiveBasicAuthentication";

/**
* Connection Manager which will be used to create {@link org.apache.http.client.HttpClient}.
* Connection Manager which will be used to create {@link org.apache.hc.client5.http.classic.HttpClient}.
* <p/>
* The value MUST be an instance of {@link org.apache.http.conn.HttpClientConnectionManager}.
* The value MUST be an instance of {@link org.apache.hc.client5.http.io.HttpClientConnectionManager}.
* <p/>
* If the property is absent a default Connection Manager will be used
* ({@link org.apache.http.impl.conn.BasicHttpClientConnectionManager}).
* ({@link org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager}).
* If you want to use this client in multi-threaded environment, be sure you override default value with
* {@link org.apache.http.impl.conn.PoolingHttpClientConnectionManager} instance.
* {@link org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager} instance.
* <p/>
* The name of the configuration property is <tt>{@value}</tt>.
*/
Expand All @@ -93,7 +94,7 @@ public final class ApacheClientProperties {
* a particular {@link org.glassfish.jersey.client.ClientRuntime} instance does not shut down the underlying
* connection manager automatically. In such case, the connection manager life-cycle
* should be fully managed by the application code. To release all allocated resources,
* caller code should especially ensure {@link org.apache.http.conn.HttpClientConnectionManager#shutdown()} gets
* caller code should especially ensure {@link org.apache.hc.client5.http.io.HttpClientConnectionManager#close()} gets
* invoked eventually.
* <p>
* This property may only be set prior to constructing Apache connector using {@link ApacheConnectorProvider}.
Expand All @@ -109,10 +110,10 @@ public final class ApacheClientProperties {
public static final String CONNECTION_MANAGER_SHARED = "jersey.config.apache.client.connectionManagerShared";

/**
* Request configuration for the {@link org.apache.http.client.HttpClient}.
* Http parameters which will be used to create {@link org.apache.http.client.HttpClient}.
* Request configuration for the {@link org.apache.hc.client5.http.classic.HttpClient}.
* Http parameters which will be used to create {@link org.apache.hc.client5.http.classic.HttpClient}.
* <p/>
* The value MUST be an instance of {@link org.apache.http.client.config.RequestConfig}.
* The value MUST be an instance of {@link org.apache.hc.client5.http.config.RequestConfig}.
* <p/>
* If the property is absent default request configuration will be used.
* <p/>
Expand All @@ -123,21 +124,21 @@ public final class ApacheClientProperties {
public static final String REQUEST_CONFIG = "jersey.config.apache.client.requestConfig";

/**
* HttpRequestRetryHandler which will be used to create {@link org.apache.http.client.HttpClient}.
* HttpRequestRetryHandler which will be used to create {@link org.apache.hc.client5.http.classic.HttpClient}.
* <p/>
* The value MUST be an instance of {@link org.apache.http.client.HttpRequestRetryHandler}.
* The value MUST be an instance of {@link org.apache.hc.client5.http.HttpRequestRetryStrategy}.
* <p/>
* If the property is absent a default retry handler will be used
* ({@link org.apache.http.impl.client.DefaultHttpRequestRetryHandler}).
* ({@link org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy}).
* <p/>
* The name of the configuration property is <tt>{@value}</tt>.
*/
public static final String RETRY_HANDLER = "jersey.config.apache.client.retryHandler";
public static final String RETRY_STRATEGY = "jersey.config.apache.client.retryStrategy";

/**
* ConnectionReuseStrategy for the {@link org.apache.http.client.HttpClient}.
* ConnectionReuseStrategy for the {@link org.apache.hc.client5.http.classic.HttpClient}.
* <p/>
* The value MUST be an instance of {@link org.apache.http.impl.ConnectionReuseStrategy}.
* The value MUST be an instance of {@link org.apache.hc.core5.http.ConnectionReuseStrategy}.
* <p/>
* If the property is absent the default reuse strategy of the Apache HTTP library will be used
* <p/>
Expand All @@ -146,9 +147,9 @@ public final class ApacheClientProperties {
public static final String REUSE_STRATEGY = "jersey.config.apache.client.reuseStrategy";

/**
* ConnectionKeepAliveStrategy for the {@link org.apache.http.client.HttpClient}.
* ConnectionKeepAliveStrategy for the {@link org.apache.hc.client5.http.classic.HttpClient}.
* <p/>
* The value MUST be an instance of {@link org.apache.http.conn.ConnectionKeepAliveStrategy}.
* The value MUST be an instance of {@link org.apache.hc.client5.http.ConnectionKeepAliveStrategy}.
* <p/>
* If the property is absent the default keepalive strategy of the Apache HTTP library will be used
* <p/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -16,8 +16,8 @@

package org.glassfish.jersey.apache.connector;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.glassfish.jersey.client.ClientRequest;

import java.io.IOException;
Expand Down
Loading

0 comments on commit 22e4b7b

Please sign in to comment.