camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r906342 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/processor/BatchProcessor.java test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
Date Thu, 04 Feb 2010 03:37:40 GMT
Author: ningjiang
Date: Thu Feb  4 03:37:40 2010
New Revision: 906342

URL: http://svn.apache.org/viewvc?rev=906342&view=rev
Log:
CAMEL-2445 applied patch with thanks to Stan and Jeff

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=906342&r1=906341&r2=906342&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java Thu
Feb  4 03:37:40 2010
@@ -27,6 +27,7 @@
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.camel.CamelException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Navigate;
 import org.apache.camel.Processor;
@@ -297,8 +298,12 @@
                         try {
                             try {
                                 sendExchanges();
-                            } catch (Exception e) {
-                                getExceptionHandler().handleException(e);
+                            } catch (Throwable t) {
+                                if (t instanceof Exception) {
+                                    getExceptionHandler().handleException(t);
+                                } else {
+                                    getExceptionHandler().handleException(new CamelException(t));
+                                }
                             }
                         } finally {
                             queueLock.lock();

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java?rev=906342&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
Thu Feb  4 03:37:40 2010
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.aggregator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class AggregatorExceptionTest extends ContextTestSupport {
+
+    public void testAggregateAndOnException() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:error");
+
+        // can change this to 5 when BatchProcessor's exception handling works properly
+        mock.expectedMessageCount(0);
+
+        for (int c = 0; c <= 10; c++) {
+            template.sendBodyAndHeader("seda:start", "Hi!", "id", 123);
+        }
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+
+                final String exceptionString = "This is an Error not an Exception";
+
+                //errorHandler(deadLetterChannel("mock:error"));
+                onException(Throwable.class).handled(true).to("mock:error");
+
+                from("seda:start")
+                    .aggregate(header("id"))
+                    .batchSize(2)
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            throw new java.lang.NoSuchMethodError(exceptionString);   
+                        }
+                    });
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message