From 2dc76d019edea34f9d79b0e6e18d9a49ae867e40 Mon Sep 17 00:00:00 2001 From: Julien Blondeau Date: Thu, 7 May 2020 20:03:41 +0200 Subject: [PATCH] Activate useSystemProperties into ApacheConnector (#4458) Signed-off-by: Julien Blondeau --- .../apache/connector/ApacheClientProperties.java | 16 +++++++++++++++- .../jersey/apache/connector/ApacheConnector.java | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheClientProperties.java b/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheClientProperties.java index 107e7498fc..d5c2ff8a01 100644 --- a/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheClientProperties.java +++ b/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheClientProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020 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 @@ -165,6 +165,20 @@ public final class ApacheClientProperties { */ public static final String CONNECTION_CLOSING_STRATEGY = "jersey.config.apache.client.connectionClosingStrategy"; + /** + * A value of {@code false} indicates the client will use default ApacheConnector params. A value + * of {@code true} will cause the client to take into account the system properties + * {@code https.protocols}, {@code https.cipherSuites}, {@code http.keepAlive}, + * {@code http.maxConnections}. + *

+ * The value MUST be an instance of {@link java.lang.Boolean}. + *

+ * The default value is {@code false}. + *

+ * The name of the configuration property is {@value}. + */ + public static final String USE_SYSTEM_PROPERTIES = "jersey.config.apache.client.useSystemProperties"; + /** * Get the value of the specified property. * diff --git a/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java b/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java index 6fe699fa71..83c15d2cbf 100644 --- a/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java +++ b/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2020 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 @@ -357,12 +357,15 @@ private HttpClientConnectionManager getConnectionManager(final Client client, } } + final boolean useSystemProperties = + PropertiesHelper.isProperty(config.getProperties(), ApacheClientProperties.USE_SYSTEM_PROPERTIES); + // Create custom connection manager. return createConnectionManager( client, config, sslContext, - false); + useSystemProperties); } private HttpClientConnectionManager createConnectionManager(