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

ASF subversion and git services commented on ARTEMIS-5947:
----------------------------------------------------------

Commit 294b0dc149c69b95c6337aced6d0be781e121b3c in artemis's branch 
refs/heads/main from Guillaume Nodet
[ https://gitbox.apache.org/repos/asf?p=artemis.git;h=294b0dc149 ]

ARTEMIS-5947: Use text block for XML config in test


> 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: 50m
>  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