From d50fbc490841252efa8b58044ac37fc813c725d8 Mon Sep 17 00:00:00 2001 From: Erwin Dondorp Date: Fri, 30 Apr 2021 13:25:13 +0100 Subject: [PATCH] ARTEMIS-3258 added warning for url parameters that are explicitly ignored --- .../core/client/ActiveMQClientLogger.java | 4 +++ .../FederationDownstreamConfiguration.java | 30 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java index 3dbf44db47..757863e867 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java @@ -574,4 +574,8 @@ public interface ActiveMQClientLogger extends BasicLogger { @Message(id = 214033, value = "Cannot resolve host ", format = Message.Format.MESSAGE_FORMAT) void unableToResolveHost(@Cause UnknownHostException e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212079, value = "The upstream connector from the downstream federation will ignore url parameter {0}", format = Message.Format.MESSAGE_FORMAT) + void ignoredParameterForDownstreamFederation(String name); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/federation/FederationDownstreamConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/federation/FederationDownstreamConfiguration.java index b85de117fd..17905e1bca 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/federation/FederationDownstreamConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/federation/FederationDownstreamConfiguration.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Objects; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; public class FederationDownstreamConfiguration extends FederationStreamConfiguration { @@ -40,23 +41,30 @@ public class FederationDownstreamConfiguration extends FederationStreamConfigura return upstreamConfiguration; } + private void stripParam(Map params, String name) { + Object oldValue = params.remove(name); + if (oldValue != null) { + ActiveMQClientLogger.LOGGER.ignoredParameterForDownstreamFederation(name); + } + } + public void setUpstreamConfiguration(TransportConfiguration transportConfiguration) { final Map params = new HashMap<>(transportConfiguration.getParams()); //clear any TLS settings as they won't apply to the federated server that uses this config //The federated server that creates the upstream back will rely on its config from the acceptor for TLS - params.remove(TransportConstants.SSL_ENABLED_PROP_NAME); - params.remove(TransportConstants.SSL_PROVIDER); - params.remove(TransportConstants.SSL_KRB5_CONFIG_PROP_NAME); - params.remove(TransportConstants.KEYSTORE_PATH_PROP_NAME); - params.remove(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME); - params.remove(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME); - params.remove(TransportConstants.KEYSTORE_TYPE_PROP_NAME); - params.remove(TransportConstants.TRUSTSTORE_PATH_PROP_NAME); - params.remove(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME); - params.remove(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME); - params.remove(TransportConstants.TRUSTSTORE_TYPE_PROP_NAME); + stripParam(params, TransportConstants.SSL_ENABLED_PROP_NAME); + stripParam(params, TransportConstants.SSL_PROVIDER); + stripParam(params, TransportConstants.SSL_KRB5_CONFIG_PROP_NAME); + stripParam(params, TransportConstants.KEYSTORE_PATH_PROP_NAME); + stripParam(params, TransportConstants.KEYSTORE_PASSWORD_PROP_NAME); + stripParam(params, TransportConstants.KEYSTORE_PROVIDER_PROP_NAME); + stripParam(params, TransportConstants.KEYSTORE_TYPE_PROP_NAME); + stripParam(params, TransportConstants.TRUSTSTORE_PATH_PROP_NAME); + stripParam(params, TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME); + stripParam(params, TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME); + stripParam(params, TransportConstants.TRUSTSTORE_TYPE_PROP_NAME); this.upstreamConfiguration = new TransportConfiguration(transportConfiguration.getFactoryClassName(), params, transportConfiguration.getName(), transportConfiguration.getExtraParams());