You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ff...@apache.org on 2024/10/23 19:39:39 UTC

(camel) 02/03: [CAMEL-21302]only set ExchangePropertyKey.CLOSE_CLIENT_SCOPE property when tracing is enabled and remove it after endScope

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

ffang pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4ef41d8a1136c2cd961fed5e246c2a97ee4804f5
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Tue Oct 22 12:25:41 2024 -0400

    [CAMEL-21302]only set ExchangePropertyKey.CLOSE_CLIENT_SCOPE property when tracing is enabled and remove it after endScope
    
    (cherry picked from commit a242355cf28ab944b71583ea4d1a67db7a0a50ba)
---
 .../main/java/org/apache/camel/component/direct/DirectProducer.java   | 4 +++-
 .../src/main/java/org/apache/camel/tracing/ActiveSpanManager.java     | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
index 221cb70ef1e..c1ff8d6a706 100644
--- a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
+++ b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
@@ -96,7 +96,9 @@ public class DirectProducer extends DefaultAsyncProducer {
                 } else {
                     //Ensure we can close the CLIENT Scope created by this DirectProducer
                     //in the same thread
-                    exchange.setProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE, Boolean.TRUE);
+                    if (exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN) != null) {
+                        exchange.setProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE, Boolean.TRUE);
+                    }
                     return consumer.getAsyncProcessor().process(exchange, callback);
                 }
             }
diff --git a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
index db4ac8b73d6..db2ba8a59ae 100644
--- a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
+++ b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
@@ -61,7 +61,7 @@ public final class ActiveSpanManager {
             //DirectProducer in async mode before we create a new INTERNAL scope
             //for the next DirectConsumer
             endScope(exchange);
-            exchange.setProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE, Boolean.FALSE);
+            exchange.removeProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE);
         }
         exchange.setProperty(ExchangePropertyKey.ACTIVE_SPAN,
                 new Holder(exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN, Holder.class), span));