camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-6610 fix the IndexOutOfBoundsException when customized id of wireTap component
Date Wed, 07 Aug 2013 07:34:04 GMT
Updated Branches:
  refs/heads/master 0d17ff78e -> ed7e7c9fe


CAMEL-6610 fix the IndexOutOfBoundsException when customized id of wireTap component


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ed7e7c9f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ed7e7c9f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ed7e7c9f

Branch: refs/heads/master
Commit: ed7e7c9feeb835fb1071b90276b1c009fed3b855
Parents: 0d17ff7
Author: Willem Jiang <ningjiang@apache.org>
Authored: Wed Aug 7 15:04:15 2013 +0800
Committer: Willem Jiang <ningjiang@apache.org>
Committed: Wed Aug 7 15:04:53 2013 +0800

----------------------------------------------------------------------
 .../org/apache/camel/model/ProcessorDefinition.java    |  8 +++++++-
 .../java/org/apache/camel/processor/WireTapTest.java   | 13 +++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ed7e7c9f/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index ff16150..9b93a1a 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -1015,6 +1015,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
             // set id on this
             setId(id);
         } else {
+            
             // set it on last output as this is what the user means to do
             // for Block(s) with non empty getOutputs() the id probably refers
             //  to the last definition in the current Block
@@ -1027,7 +1028,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
                     }
                 }
             }
-            outputs.get(outputs.size() - 1).setId(id);
+            if (!getOutputs().isEmpty()) {
+                outputs.get(outputs.size() - 1).setId(id);
+            } else {
+                // the output could be empty
+                setId(id);
+            }
         }
 
         return (Type) this;

http://git-wip-us.apache.org/repos/asf/camel/blob/ed7e7c9f/camel-core/src/test/java/org/apache/camel/processor/WireTapTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/WireTapTest.java b/camel-core/src/test/java/org/apache/camel/processor/WireTapTest.java
index 266cd49..3c45d54 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/WireTapTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/WireTapTest.java
@@ -38,6 +38,16 @@ public class WireTapTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
     }
+    
+    public void testWireTapId() throws Exception {
+        MockEndpoint a = getMockEndpoint("mock:a");
+        MockEndpoint b = getMockEndpoint("mock:b");
+        a.expectedBodiesReceived("Hello");
+        b.expectedBodiesReceived("Hello");
+        
+        template.sendBody("direct:test", "Hello");
+        assertMockEndpointsSatisfied();
+    }
 
     @Override
     protected void setUp() throws Exception {
@@ -59,6 +69,9 @@ public class WireTapTest extends ContextTestSupport {
                 from("direct:tap")
                     .delay(1000).setBody().constant("Tapped")
                     .to("mock:result", "mock:tap");
+                
+                from("direct:test").wireTap("direct:a").id("wiretap_1").to("mock:a");
+                from("direct:a").to("mock:b");
             }
         };
     }


Mime
View raw message