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 b172942f4b..e476dcb20a 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 @@ -425,11 +425,6 @@ public interface ActiveMQClientLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void broadcastTimeout(int retry, int maxretry); - @LogMessage(level = Logger.Level.WARN) - @Message(id = 212078, value = "Connection factory parameter ignored {0}", - format = Message.Format.MESSAGE_FORMAT) - void connectionFactoryParameterIgnored(String parameterName); - @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/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java index be4a9cfb93..a8c81e5258 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java @@ -279,7 +279,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C // to create a connector just to validate if the parameters are ok. // so this will create the instance to be used on the isEquivalent check if (localConnector == null) { - localConnector = connectorFactory.createConnector(currentConnectorConfig.getParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager); + localConnector = connectorFactory.createConnector(currentConnectorConfig.getCombinedParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager); } if (localConnector.isEquivalent(live.getParams()) && backUp != null && !localConnector.isEquivalent(backUp.getParams()) @@ -1127,7 +1127,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C } protected Connector createConnector(ConnectorFactory connectorFactory, TransportConfiguration configuration) { - Connector connector = connectorFactory.createConnector(configuration.getParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager); + Connector connector = connectorFactory.createConnector(configuration.getCombinedParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager); if (connector instanceof NettyConnector) { NettyConnector nettyConnector = (NettyConnector) connector; if (nettyConnector.getConnectTimeoutMillis() < 0) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java index 1dec42c254..35a0bb3cfd 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java @@ -174,7 +174,7 @@ public class BackwardsCompatibilityUtils { private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); - return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); + return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName(), convertParameters(tc.getExtraParams())); } return tc; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java index b7b6c41c01..48a141f676 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java @@ -66,7 +66,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { StringBuilder fragment = new StringBuilder(); for (int i = 1; i < staticConnectors.length; i++) { TransportConfiguration connector = staticConnectors[i]; - Map params = escapeIPv6Host(connector.getParams()); + Map params = escapeIPv6Host(connector.getCombinedParams()); URI extraUri = new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, null), null); if (i > 1) { fragment.append(","); @@ -74,7 +74,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { fragment.append(extraUri.toASCIIString()); } - Map params = escapeIPv6Host(staticConnectors[0].getParams()); + Map params = escapeIPv6Host(staticConnectors[0].getCombinedParams()); return new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, query), fragment.toString()); } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java index f97da986bd..e8cb8ea792 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java @@ -23,7 +23,6 @@ import java.util.Properties; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -31,9 +30,12 @@ import org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfiguratio import org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.SchemaConstants; +import org.jboss.logging.Logger; public class TCPSchema extends AbstractCFSchema { + private static final Logger logger = Logger.getLogger(TCPSchema.class); + @Override public String getSchemaName() { return SchemaConstants.TCP; @@ -83,7 +85,7 @@ public class TCPSchema extends AbstractCFSchema { if (!key.equals("ha") && !key.equals("type") && !TransportConstants.ALLOWABLE_CONNECTOR_KEYS.contains(key) && !factoryProperties.containsKey(key)) { - ActiveMQClientLogger.LOGGER.connectionFactoryParameterIgnored(key); + logger.debugf("Connection factory parameter %s is not standard", key); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java index 054faccb4f..d6ae6b8440 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java @@ -445,12 +445,18 @@ public class CoreProtocolManager implements ProtocolManager params = new HashMap<>(acceptorUsed.getConfiguration()); - params.putAll(upstreamConfig.getParams()); + if (upstreamConfig.getParams() != null) { + params.putAll(upstreamConfig.getParams()); + } + final Map extraParams = new HashMap<>(); + if (upstreamConfig.getExtraParams() != null) { + extraParams.putAll(upstreamConfig.getExtraParams()); + } //Add the new upstream configuration that was created so we can connect back to the downstream server final TransportConfiguration upstreamConf = new TransportConfiguration( upstreamConfig.getFactoryClassName(), params, upstreamConfig.getName() + FederationDownstreamConnectMessage.UPSTREAM_SUFFIX, - new HashMap<>()); + extraParams); server.getConfiguration() .addConnectorConfiguration(upstreamConf.getName() + FederationDownstreamConnectMessage.UPSTREAM_SUFFIX, upstreamConf); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/BackupActivationNoReconnectTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/BackupActivationNoReconnectTest.java index d19f38e5fa..5a6a21117e 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/BackupActivationNoReconnectTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/BackupActivationNoReconnectTest.java @@ -168,7 +168,7 @@ public class BackupActivationNoReconnectTest { when(connectorConfig.getFactoryClassName()).thenReturn(NettyConnectorFactory.class.getName()); Map urlParams = new HashMap<>(); urlParams.put("port", serverSocket.getLocalPort()); - when(connectorConfig.getParams()).thenReturn(urlParams); + when(connectorConfig.getCombinedParams()).thenReturn(urlParams); ClientSessionFactoryImpl sessionFactory = new ClientSessionFactoryImpl(serverLocator, connectorConfig, locatorConfig, reconnectAttempts, threadPool, scheduledThreadPool, null, null); when(clusterControl.getSessionFactory()).thenReturn(sessionFactory); when(clientProtocolManager.isAlive()).thenReturn(true); diff --git a/tests/config/logging.properties b/tests/config/logging.properties index 2742facd8d..6793dc1343 100644 --- a/tests/config/logging.properties +++ b/tests/config/logging.properties @@ -17,13 +17,14 @@ # Additional logger names to configure (root logger is always configured) # Root logger option -loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.core.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.smoke,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.cli.test,org.apache.activemq.audit,org.apache.activemq.audit.message +loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.core.journal,org.apache.activemq.artemis.core.client,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.smoke,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.cli.test,org.apache.activemq.audit,org.apache.activemq.audit.message # Root logger level logger.level=INFO # ActiveMQ Artemis logger levels logger.org.apache.activemq.artemis.core.server.level=INFO logger.org.apache.activemq.artemis.core.journal.level=INFO +logger.org.apache.activemq.artemis.core.client.level=INFO logger.org.apache.activemq.artemis.utils.level=INFO logger.org.apache.activemq.artemis.jms.level=INFO logger.org.apache.activemq.artemis.ra.level=INFO diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java index 679de803f7..7f0bd43ce3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java @@ -36,6 +36,7 @@ import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.BroadcastEndpoint; @@ -59,6 +60,7 @@ import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.Wait; +import org.jboss.logmanager.LogManager; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -89,6 +91,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { ctx.lookup("TCPConnectionFactory"); ctx.lookup("UDPConnectionFactory"); ctx.lookup("JGroupsConnectionFactory"); + ctx.close(); } @Test @@ -101,6 +104,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("ConnectionFactory"); connectionFactory.createConnection().close(); + ctx.close(); } @Test @@ -111,22 +115,26 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { //IIB v10 assumes this property is mandatory and sets it to an empty string when not specified props.put("java.naming.provider.url", ""); - new InitialContext(props);//Must not throw an exception - + Context ctx = new InitialContext(props);//Must not throw an exception + ctx.close(); } @Test public void testConnectionFactoryStringWithInvalidParameter() throws Exception { + Level initialLevel = LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").getLevel(); + LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").setLevel(Level.ALL); Hashtable props = new Hashtable<>(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); props.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?foo=too"); AssertionLoggerHandler.startCapture(); try { - new InitialContext(props); - assertTrue("Expected to find AMQ212078", AssertionLoggerHandler.findText("AMQ212078")); + Context ctx = new InitialContext(props); + ctx.close(); + assertTrue("Connection factory parameter foo is not standard", AssertionLoggerHandler.findText("Connection factory parameter foo is not standard")); } finally { AssertionLoggerHandler.stopCapture(); + LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").setLevel(initialLevel); } } @@ -267,6 +275,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("myConnectionFactory"); connectionFactory.createConnection().close(); + ctx.close(); } @Test @@ -292,6 +301,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { Assert.assertNotEquals(1198, udpBroadcastEndpointFactory.getLocalBindPort()); Assert.assertEquals(getUDPDiscoveryAddress(), udpBroadcastEndpointFactory.getGroupAddress()); Assert.assertEquals(getUDPDiscoveryPort(), udpBroadcastEndpointFactory.getGroupPort()); + ctx.close(); } @Test @@ -304,6 +314,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("myConnectionFactory"); connectionFactory.createConnection().close(); + ctx.close(); } @Test @@ -379,6 +390,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropMaskPassword()), "myPropMaskPassword"); Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropPasswordCodec()), "myPropPasswordCodec"); Assert.assertEquals(parametersFromJNDI.get(TransportConstants.NETTY_CONNECT_TIMEOUT), "myNettyConnectTimeout"); + ctx.close(); } @Override