You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/02/19 08:54:11 UTC

[camel] branch master updated: Id set on recipient list EIP should be on the processor and not the wrapping pipeline

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5e24da3  Id set on recipient list EIP should be on the processor and not the wrapping pipeline
5e24da3 is described below

commit 5e24da3069037f144c39e6082522f55b57277af7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 19 09:39:06 2020 +0100

    Id set on recipient list EIP should be on the processor and not the wrapping pipeline
---
 .../org/apache/camel/processor/RecipientList.java  | 34 ++++++++++++++++++++++
 .../apache/camel/reifier/RecipientListReifier.java |  5 ++--
 .../camel/processor/RecipientListNoCacheTest.java  |  4 +--
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/RecipientList.java b/core/camel-base/src/main/java/org/apache/camel/processor/RecipientList.java
index b6f173f..1ddea1a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/RecipientList.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/RecipientList.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.processor;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.ExecutorService;
 
@@ -102,6 +103,39 @@ public class RecipientList extends AsyncProcessorSupport implements IdAware, Rou
         this.delimiter = delimiter;
     }
 
+    /**
+     * Wrap {@link RecipientList} in {@link Pipeline}.
+     */
+    private final class RecipientListPipeline extends Pipeline {
+
+        private final RecipientList recipientList;
+
+        public RecipientListPipeline(RecipientList recipientList, CamelContext camelContext, Collection<Processor> processors) {
+            super(camelContext, processors);
+            this.recipientList = recipientList;
+        }
+
+        @Override
+        public void setId(String id) {
+            // we want to set the id on the recipient list and not this wrapping pipeline
+            recipientList.setId(id);
+        }
+
+        @Override
+        public String getId() {
+            return null;
+        }
+
+        @Override
+        public String toString() {
+            return null;
+        }
+    }
+
+    public Processor newPipeline(CamelContext camelContext, Collection<Processor> processors) {
+        return new RecipientListPipeline(this, camelContext, processors);
+    }
+
     @Override
     public String toString() {
         return id;
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
index 6016e4a..e1602f3 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
@@ -106,9 +106,8 @@ public class RecipientListReifier extends ProcessorReifier<RecipientListDefiniti
         pipe.add(evalProcessor);
         pipe.add(answer);
 
-        // wrap in nested pipeline so this appears as one processor
-        // (threads definition does this as well)
-        return new Pipeline(camelContext, pipe);
+        // wrap recipient list in nested pipeline so this appears as one processor
+        return answer.newPipeline(camelContext, pipe);
     }
 
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoCacheTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoCacheTest.java
index a65fed8..2660405 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoCacheTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListNoCacheTest.java
@@ -45,9 +45,7 @@ public class RecipientListNoCacheTest extends ContextTestSupport {
 
         // make sure its using an empty producer cache as the cache is disabled
         List<Processor> list = context.getRoute("route1").filter("foo");
-        // the id is set on the pipeline as recipient list is wrapped
-        Pipeline pipe = (Pipeline) list.get(0);
-        RecipientList rl = (RecipientList) pipe.next().get(1);
+        RecipientList rl = (RecipientList) list.get(0);
         assertNotNull(rl);
         assertEquals(-1, rl.getCacheSize());