Return-Path: Delivered-To: apmail-activemq-camel-commits-archive@locus.apache.org Received: (qmail 55428 invoked from network); 11 Oct 2008 10:18:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Oct 2008 10:18:16 -0000 Received: (qmail 85665 invoked by uid 500); 11 Oct 2008 10:18:16 -0000 Delivered-To: apmail-activemq-camel-commits-archive@activemq.apache.org Received: (qmail 85633 invoked by uid 500); 11 Oct 2008 10:18:15 -0000 Mailing-List: contact camel-commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-commits@activemq.apache.org Received: (qmail 85624 invoked by uid 99); 11 Oct 2008 10:18:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Oct 2008 03:18:15 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Oct 2008 10:17:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ED89D23888A4; Sat, 11 Oct 2008 03:17:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r703643 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/ main/java/org/apache/camel/util/ test/java/org/apache/camel/issues/ Date: Sat, 11 Oct 2008 10:17:54 -0000 To: camel-commits@activemq.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081011101754.ED89D23888A4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Sat Oct 11 03:17:50 2008 New Revision: 703643 URL: http://svn.apache.org/viewvc?rev=703643&view=rev Log: CAMEL-960: fixed boolean not used CAMEL-901: added unit test for looking into this rare issue polished code and fixed wrong wrapping of exceptions Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java (with props) Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=703643&r1=703642&r2=703643&view=diff ============================================================================== --- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original) +++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Sat Oct 11 03:17:50 2008 @@ -35,6 +35,7 @@ String AGGREGATED_COUNT = "org.apache.camel.Exchange.AggregatedCount"; String EXCEPTION_HANDLED_PROPERTY = "CamelExceptionHandled"; + /** * Returns the {@link ExchangePattern} (MEP) of this exchange. * Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java?rev=703643&r1=703642&r2=703643&view=diff ============================================================================== --- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java (original) +++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java Sat Oct 11 03:17:50 2008 @@ -48,7 +48,7 @@ @XmlElement(name = "exception") private List exceptions = new ArrayList(); - @XmlElement(name = "redeliveryPolicy", required = false) + @XmlElement(name = "redeliveryPolicy", required = false) private RedeliveryPolicyType redeliveryPolicy; @XmlElementRef private List> outputs = new ArrayList>(); @@ -121,7 +121,7 @@ //------------------------------------------------------------------------- public ExceptionType handled(boolean cond) { ConstantLanguage constant = new ConstantLanguage(); - return handled(constant.createPredicate("true")); + return handled(constant.createPredicate(Boolean.toString(cond))); } public ExceptionType handled(Predicate cond) { Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=703643&r1=703642&r2=703643&view=diff ============================================================================== --- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java (original) +++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java Sat Oct 11 03:17:50 2008 @@ -86,7 +86,7 @@ @Override public String toString() { - return "DeadLetterChannel[" + output + ", " + deadLetter + ", " + redeliveryPolicy + "]"; + return "DeadLetterChannel[" + output + ", " + deadLetter + "]"; } public boolean process(Exchange exchange, final AsyncCallback callback) { Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=703643&r1=703642&r2=703643&view=diff ============================================================================== --- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original) +++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Sat Oct 11 03:17:50 2008 @@ -604,7 +604,7 @@ try { return type.newInstance(); } catch (InstantiationException e) { - throw new RuntimeCamelException(e.getCause()); + throw new RuntimeCamelException(e); } catch (IllegalAccessException e) { throw new RuntimeCamelException(e); } @@ -618,7 +618,7 @@ Object value = actualType.newInstance(); return cast(expectedType, value); } catch (InstantiationException e) { - throw new RuntimeCamelException(e.getCause()); + throw new RuntimeCamelException(); } catch (IllegalAccessException e) { throw new RuntimeCamelException(e); } Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java?rev=703643&view=auto ============================================================================== --- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java (added) +++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java Sat Oct 11 03:17:50 2008 @@ -0,0 +1,102 @@ +/** + * 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.issues; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.builder.RouteBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Unit test to verify that error handling using thread() pool also works as expected. + */ +public class BelasThreadErrorHandlerIssue901Test extends ContextTestSupport { + private static final transient Log LOG = LogFactory.getLog(BelasThreadErrorHandlerIssue901Test.class); + private String msg1 = "Message Intended For Processor #1", + msg2 = "Message Intended For Processor #2", + msg3 = "Message Intended For Processor #3"; + private int callCounter1 = 0, callCounter2 = 0, callCounter3 = 0; + private int redelivery = 1; + + protected void setUp() throws Exception { + disableJMX(); + super.setUp(); + } + + public void testThreadErrorHandlerLogging() throws Exception { + MockEndpoint handled = getMockEndpoint("mock:handled"); + + template.sendBody("seda:errorTest", msg1); + + handled.expectedMessageCount(1); + handled.expectedBodiesReceived(msg3); + + // TODO: Enable this when looking into this issue + //Thread.sleep(3000); + + assertMockEndpointsSatisfied(); + + assertEquals(1, callCounter1); + assertEquals(1, callCounter2); + assertEquals(1 + redelivery, callCounter3); // Only this should be more then 1 + } + + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() throws Exception { + //getContext().addInterceptStrategy(new Tracer()); + errorHandler(deadLetterChannel("mock:handled").maximumRedeliveries(redelivery)); + + from("seda:errorTest") + // TODO: When using thread there is a multi threading / concurreny issue in Camel + // hard to debug as it tend only to surface when unit test is running really fast + // (no break points) + + //.thread(5).maxSize(5) + // Processor #1 + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + callCounter1++; + LOG.debug("Processor #1 Received A " + exchange.getIn().getBody()); + exchange.getOut().setBody(msg2); + } + }) + // Processor #2 + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + callCounter2++; + LOG.debug("Processor #2 Received A " + exchange.getIn().getBody()); + exchange.getOut().setBody(msg3); + } + }) + // Processor #3 + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + //Thread.sleep(100); + callCounter3++; + LOG.debug("Processor #3 Received A " + exchange.getIn().getBody()); + throw new Exception("Forced exception by unit test"); + } + }); + } + }; + } + +} Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/BelasThreadErrorHandlerIssue901Test.java ------------------------------------------------------------------------------ svn:keywords = Rev Date