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 165c5da1c1 Make JmsListenerFactory final with a private constructor
165c5da1c1 is described below
commit 165c5da1c18959a9341cfef9865cc38c7f7d17cb
Author: Mridul Pathak <[email protected]>
AuthorDate: Sat Oct 31 12:41:09 2026 +0530
Make JmsListenerFactory final with a private constructor
JmsListenerFactory is a process-wide singleton: its only caller,
ServiceDispatcher, goes through getInstance, and the listener and server maps
it fills are static, so a second instance created with the public constructor
or through a subclass could only start a second loader thread over the same
maps. The public constructor, which started the loader thread while the object
was still being built, is removed and the class is final. The private
constructor only stores the delegator, and [...]
---
.../org/apache/ofbiz/service/jms/JmsListenerFactory.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 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 3cf1b611b8..a74fd5a789 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
@@ -39,7 +39,7 @@ import org.apache.ofbiz.service.config.model.Server;
/**
* JmsListenerFactory
*/
-public class JmsListenerFactory implements Runnable {
+public final class JmsListenerFactory implements Runnable {
private static final String MODULE = JmsListenerFactory.class.getName();
@@ -51,7 +51,7 @@ public class JmsListenerFactory implements Runnable {
private static final AtomicReference<JmsListenerFactory> JL_FACTORY_REF =
new AtomicReference<>(null);
- private Delegator delegator;
+ private final Delegator delegator;
private boolean firstPass = true;
private int loadable = 0;
private int connected = 0;
@@ -61,7 +61,7 @@ public class JmsListenerFactory implements Runnable {
public static JmsListenerFactory getInstance(Delegator delegator) {
JmsListenerFactory instance = JL_FACTORY_REF.get();
if (instance == null) {
- JmsListenerFactory created = new JmsListenerFactory(delegator,
false);
+ JmsListenerFactory created = new JmsListenerFactory(delegator);
if (JL_FACTORY_REF.compareAndSet(null, created)) {
// only the published instance runs the loader thread
created.start();
@@ -73,15 +73,8 @@ public class JmsListenerFactory implements Runnable {
return instance;
}
- public JmsListenerFactory(Delegator delegator) {
- this(delegator, true);
- }
-
- private JmsListenerFactory(Delegator delegator, boolean start) {
+ private JmsListenerFactory(Delegator delegator) {
this.delegator = delegator;
- if (start) {
- start();
- }
}
private void start() {