This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new edd710df84 Start the JMS listener factory thread only for the
published instance
edd710df84 is described below
commit edd710df84a7697df9918b68436094a4c894c576
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Oct 30 19:58:14 2026 +0530
Start the JMS listener factory thread only for the published instance
JmsListenerFactory.getInstance created a factory whose constructor already
started the listener loader thread, and only then tried to publish it with
compareAndSet. When two dispatchers were created at the same time, the instance
that lost the race was discarded but its thread kept loading listeners into the
same static maps, under a different lock, so the same JMS listener could be
created and connected twice and the extra one was never closed. getInstance now
builds the factory with [...]
---
.../apache/ofbiz/service/jms/JmsListenerFactory.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
b/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
index 537859793c..3cf1b611b8 100644
---
a/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
+++
b/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
@@ -61,8 +61,12 @@ public class JmsListenerFactory implements Runnable {
public static JmsListenerFactory getInstance(Delegator delegator) {
JmsListenerFactory instance = JL_FACTORY_REF.get();
if (instance == null) {
- instance = new JmsListenerFactory(delegator);
- if (!JL_FACTORY_REF.compareAndSet(null, instance)) {
+ JmsListenerFactory created = new JmsListenerFactory(delegator,
false);
+ if (JL_FACTORY_REF.compareAndSet(null, created)) {
+ // only the published instance runs the loader thread
+ created.start();
+ instance = created;
+ } else {
instance = JL_FACTORY_REF.get();
}
}
@@ -70,7 +74,17 @@ public class JmsListenerFactory implements Runnable {
}
public JmsListenerFactory(Delegator delegator) {
+ this(delegator, true);
+ }
+
+ private JmsListenerFactory(Delegator delegator, boolean start) {
this.delegator = delegator;
+ if (start) {
+ start();
+ }
+ }
+
+ private void start() {
thread = new Thread(this, this.toString());
thread.setDaemon(false);
thread.start();