[ 
https://issues.apache.org/jira/browse/ARTEMIS-5947?focusedWorklogId=1008905&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1008905
 ]

ASF GitHub Bot logged work on ARTEMIS-5947:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Mar/26 20:15
            Start Date: 10/Mar/26 20:15
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #6286:
URL: https://github.com/apache/artemis/pull/6286#discussion_r2914197810


##########
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"; +

Review Comment:
   It would be nicer to use `"""` here instead of all the `\n` and `+`.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1008905)
    Time Spent: 20m  (was: 10m)

> ActiveMQServers.newActiveMQServer(String, MBeanServer, SecurityManager) 
> hardcodes enablePersistence=true, ignoring XML configuration
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-5947
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5947
>             Project: Artemis
>          Issue Type: Bug
>    Affects Versions: 2.44.0
>            Reporter: Guillaume Nodet
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> h3. Summary
>   {{ActiveMQServers.newActiveMQServer(String configURL, MBeanServer, 
> ActiveMQSecurityManager)}} hardcodes {{enablePersistence=true}},
>   silently ignoring the XML configuration's 
> {{<persistence-enabled>false</persistence-enabled>}}.
>   h3. Details
>   The 3-arg method parses an XML configuration file but then calls the 3-arg 
> {{newActiveMQServer(Configuration, MBeanServer,
>   ActiveMQSecurityManager)}} which delegates to the 4-arg version with 
> {{enablePersistence=true}} hardcoded:
>   {code:java}
>   public static ActiveMQServer newActiveMQServer(final String configURL,
>                                                  final MBeanServer 
> mbeanServer,
>                                                  final 
> ActiveMQSecurityManager securityManager) throws Exception {
>       FileConfiguration config = new FileConfiguration();
>       LegacyJMSConfiguration legacyJMSConfiguration = new 
> LegacyJMSConfiguration(config);
>       new FileDeploymentManager(configURL)
>           
> .addDeployable(config).addDeployable(legacyJMSConfiguration).readConfiguration();
>       // This calls the 3-arg version which hardcodes enablePersistence=true:
>       ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, 
> mbeanServer, securityManager);
>       return server;
>   }
>   public static ActiveMQServer newActiveMQServer(final Configuration config,
>                                                  final MBeanServer 
> mbeanServer,
>                                                  final 
> ActiveMQSecurityManager securityManager) {
>       // Hardcodes enablePersistence=true, overriding the XML's 
> <persistence-enabled>false</persistence-enabled>
>       ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, 
> mbeanServer, securityManager, true);
>       return server;
>   }
>   {code}
>   The 4-arg method does {{config.setPersistenceEnabled(enablePersistence)}}, 
> overriding whatever was parsed from XML.
>   h3. Impact
>   On JDK 25 (macOS), enabling persistence causes the embedded broker to get 
> stuck in {{STARTING}} state during journal initialization,
>   likely due to JDK 25's tighter native access restrictions 
> ({{System::loadLibrary}} warnings from {{activemq-artemis-native}}) affecting
>   the AIO to NIO journal fallback path. The broker never transitions to 
> {{STARTED}}, and {{waitForActivation()}} times out.
>   h3. Suggested fix
>   The {{newActiveMQServer(String, MBeanServer, SecurityManager)}} method 
> should honor the parsed XML configuration's persistence setting:
>   {code:java}
>   public static ActiveMQServer newActiveMQServer(final String configURL,
>                                                  final MBeanServer 
> mbeanServer,
>                                                  final 
> ActiveMQSecurityManager securityManager) throws Exception {
>       FileConfiguration config = new FileConfiguration();
>       LegacyJMSConfiguration legacyJMSConfiguration = new 
> LegacyJMSConfiguration(config);
>       new FileDeploymentManager(configURL)
>           
> .addDeployable(config).addDeployable(legacyJMSConfiguration).readConfiguration();
>       // Use config.isPersistenceEnabled() instead of hardcoding true
>       ActiveMQServer server = ActiveMQServers.newActiveMQServer(
>           config, mbeanServer, securityManager, 
> config.isPersistenceEnabled());
>       return server;
>   }
>   {code}
>   h3. Workaround
>   Parse the XML manually and call the 4-arg version directly:
>   {code:java}
>   FileConfiguration config = new FileConfiguration();
>   LegacyJMSConfiguration legacyJMSConfiguration = new 
> LegacyJMSConfiguration(config);
>   new FileDeploymentManager(configURL)
>       
> .addDeployable(config).addDeployable(legacyJMSConfiguration).readConfiguration();
>   activeMQServer = ActiveMQServers.newActiveMQServer(config, null, 
> securityManager, false);
>   {code}
>   h3. Environment
>   * Artemis 2.44.0
>   * JDK 25 (Temurin 25.0.2+10)
>   * macOS (Darwin)
>   Discovered via Apache Camel {{JmsToJmsTransactedSecurityIT}} test failure.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to