Author: romkal
Date: Tue Apr 1 12:50:40 2008
New Revision: 643540
URL: http://svn.apache.org/viewvc?rev=643540&view=rev
Log:
CAMEL-422 : handleAll() were not executed when exception thrown from handle()
clause
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithErrorInHandleAndFinallyBlockTest.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java?rev=643540&r1=643539&r2=643540&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
Tue Apr 1 12:50:40 2008
@@ -73,15 +73,26 @@
LOG.info("Caught exception while processing exchange.", e);
handleException(exchange, e);
}
- processFinally(exchange);
} catch (Exception ex) {
unexpected = ex;
} catch (Throwable ex) {
unexpected = new RuntimeCamelException(ex);
+ } finally {
+ try {
+ processFinally(exchange);
+ } catch (Exception ex) {
+ unexpected = ex;
+ } catch (Throwable ex) {
+ unexpected = new RuntimeCamelException(ex);
+ }
+ if (unexpected != null) {
+ LOG.warn("Caught exception inside processFinally clause.",
unexpected);
+ throw unexpected;
+ }
}
if (unexpected != null) {
- LOG.warn("Caught exception inside catch clause.", unexpected);
+ LOG.warn("Caught exception inside handle clause.", unexpected);
throw unexpected;
}
}
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithErrorInHandleAndFinallyBlockTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithErrorInHandleAndFinallyBlockTest.java?rev=643540&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithErrorInHandleAndFinallyBlockTest.java
(added)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithErrorInHandleAndFinallyBlockTest.java
Tue Apr 1 12:50:40 2008
@@ -0,0 +1,42 @@
+/**
+ * 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;
+
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+
+public class ValidationWithErrorInHandleAndFinallyBlockTest extends
ValidationTest {
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .errorHandler(noErrorHandler())
+ .tryBlock()
+ .process(validator)
+ .handle(ValidationException.class)
+ .process(validator)
+ .finallyBlock()
+ .choice()
+ .when(header("foo").isEqualTo("bar"))
+ .to("mock:valid")
+ .otherwise()
+ .to("mock:invalid");
+ }
+ };
+ }
+
+}