This is an automated email from the ASF dual-hosted git repository. clebertsuconic pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/artemis.git
commit aba64df15f14fce3b5f2379731d6f1ab167bac6d Author: Guillaume Nodet <[email protected]> AuthorDate: Tue Mar 10 21:02:00 2026 +0100 ARTEMIS-5947: Fix newActiveMQServer(String,...) ignoring XML persistence-enabled setting The 3-arg newActiveMQServer(String, MBeanServer, ActiveMQSecurityManager) method was calling the 3-arg newActiveMQServer(Configuration, MBeanServer, SecurityManager) which hardcodes enablePersistence=true, overriding whatever was parsed from the XML configuration file. Changed to call the 4-arg version with config.isPersistenceEnabled() to preserve the XML setting. --- .../artemis/core/server/ActiveMQServers.java | 2 +- .../artemis/core/server/ActiveMQServersTest.java | 52 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServers.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServers.java index 67379f3e93..af92b227cb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServers.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServers.java @@ -75,7 +75,7 @@ public final class ActiveMQServers { LegacyJMSConfiguration legacyJMSConfiguration = new LegacyJMSConfiguration(config); new FileDeploymentManager(configURL).addDeployable(config).addDeployable(legacyJMSConfiguration).readConfiguration(); - ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, mbeanServer, securityManager); + ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, mbeanServer, securityManager, config.isPersistenceEnabled()); return server; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/ActiveMQServersTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/ActiveMQServersTest.java new file mode 100644 index 0000000000..45d71496f0 --- /dev/null +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/ActiveMQServersTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.core.server; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration; +import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; +import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +public class ActiveMQServersTest { + + @Test + public void testNewActiveMQServerFromConfigURLRespectsXmlPersistenceEnabled(@TempDir Path tempDir) throws Exception { + Path configFile = tempDir.resolve("broker.xml"); + String xml = "<configuration xmlns=\"urn:activemq\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + + " xsi:schemaLocation=\"urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd\">\n" + + " <core xmlns=\"urn:activemq:core\">\n" + + " <persistence-enabled>false</persistence-enabled>\n" + + " <acceptors>\n" + + " <acceptor name=\"vm\">vm://0</acceptor>\n" + + " </acceptors>\n" + + " </core>\n" + + "</configuration>\n"; + Files.writeString(configFile, xml); + + ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration()); + ActiveMQServer server = ActiveMQServers.newActiveMQServer(configFile.toUri().toURL().toExternalForm(), null, securityManager); + + assertFalse(server.getConfiguration().isPersistenceEnabled(), + "persistence-enabled should be false as specified in XML configuration"); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
