You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/31 11:17:39 UTC

[camel] branch main updated: CAMEL-19815: avoid using invalid QueueReferences (#11253)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new d66469d6ac7 CAMEL-19815: avoid using invalid QueueReferences (#11253)
d66469d6ac7 is described below

commit d66469d6ac7243f0ae790c41a500965b885d3180
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Aug 31 13:17:32 2023 +0200

    CAMEL-19815: avoid using invalid QueueReferences (#11253)
    
    This partially reverts the changes introduced on 23542fc5b65f33cde0f74f71876fe80d8c8c853f and b70584ddb3545a87acc1732f0e89b9cea704c461
---
 .../apache/camel/component/seda/SedaEndpoint.java  | 25 ++++++----------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
index 1131e44a68a..e59dc325e1e 100644
--- a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
+++ b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
@@ -101,7 +101,6 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
     private boolean discardIfNoConsumers;
 
     private BlockingQueueFactory<Exchange> queueFactory;
-    private volatile QueueReference ref;
 
     public SedaEndpoint() {
         queueFactory = new LinkedBlockingQueueFactory<>();
@@ -215,23 +214,14 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
      * @return the reference, or <tt>null</tt> if no queue reference exists.
      */
     public QueueReference getQueueReference() {
-        if (ref == null) {
-            ref = tryQueueRefInit();
-        }
-
-        return ref;
-    }
+        String key = getComponent().getQueueKey(getEndpointUri());
 
-    private QueueReference tryQueueRefInit() {
-        final SedaComponent component = getComponent();
-        if (component != null) {
-            final String key = component.getQueueKey(getEndpointUri());
-            return component.getQueueReference(key);
+        synchronized (this) {
+            return getComponent().getQueueReference(key);
         }
-
-        return null;
     }
 
+
     protected synchronized AsyncProcessor getConsumerMulticastProcessor() {
         if (!multicastStarted && consumerMulticastProcessor != null) {
             // only start it on-demand to avoid starting it during stopping
@@ -557,8 +547,6 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
         if (queue == null) {
             queue = getQueue();
         }
-
-        ref = tryQueueRefInit();
     }
 
     @Override
@@ -568,8 +556,6 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
         } else {
             LOG.debug("There is still active consumers.");
         }
-
-        ref = null;
     }
 
     @Override
@@ -601,7 +587,8 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
 
         // clear queue, as we are shutdown, so if re-created then the queue must be updated
         queue = null;
-        ref = null;
     }
 
+
+
 }