diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java index f38872f627..d7026b6297 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java @@ -56,7 +56,7 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory { Map data = new ConcurrentHashMap<>(); String providerUrl = (String) environment.get(javax.naming.Context.PROVIDER_URL); - if (providerUrl != null) { + if (providerUrl != null && !providerUrl.isEmpty()) { try { JMSFactoryType providedFactoryType = getFactoryType(providerUrl); if (providedFactoryType == null) { 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 c9299aabcd..c93f67bf55 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 @@ -103,6 +103,18 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase { connectionFactory.createConnection().close(); } + @Test + public void testEmptyConnectionFactoryString() throws NamingException, JMSException { + Hashtable props = new Hashtable<>(); + props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); + props.put("connectionFactory.ConnectionFactory", "vm://0"); + + //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 + + } + @Test public void testVMCF1() throws NamingException, JMSException { Hashtable props = new Hashtable<>();