Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 673CFD80D for ; Thu, 7 Mar 2013 08:52:34 +0000 (UTC) Received: (qmail 65211 invoked by uid 500); 7 Mar 2013 08:52:34 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 65164 invoked by uid 500); 7 Mar 2013 08:52:33 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 65150 invoked by uid 99); 7 Mar 2013 08:52:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2013 08:52:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Thu, 07 Mar 2013 08:52:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 15E25238897F; Thu, 7 Mar 2013 08:52:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1453737 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java camel-core/src/test/java/org/apache/camel/impl/CompositeRegistryTest.java Date: Thu, 07 Mar 2013 08:52:11 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130307085212.15E25238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Thu Mar 7 08:52:11 2013 New Revision: 1453737 URL: http://svn.apache.org/r1453737 Log: CAMEL-6135 CompositeRegistry should catch the exception when it lookup the component across the registries Merged revisions 1453733 via svnmerge from https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x ................ r1453733 | ningjiang | 2013-03-07 16:43:42 +0800 (Thu, 07 Mar 2013) | 10 lines Merged revisions 1453704 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1453704 | ningjiang | 2013-03-07 14:23:24 +0800 (Thu, 07 Mar 2013) | 1 line CAMEL-6135 CompositeRegistry should catch the exception when it lookup the component across the registries ........ ................ Added: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/impl/CompositeRegistryTest.java - copied unchanged from r1453733, camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/CompositeRegistryTest.java Modified: camel/branches/camel-2.9.x/ (props changed) camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1453704 Merged /camel/branches/camel-2.10.x:r1453733 Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java?rev=1453737&r1=1453736&r2=1453737&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java Thu Mar 7 08:52:11 2013 @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import org.apache.camel.NoSuchBeanException; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.Registry; /** @@ -44,22 +45,28 @@ public class CompositeRegistry implement public T lookup(String name, Class type) { T answer = null; + RuntimeCamelException ex = null; for (Registry registry : registryList) { try { answer = registry.lookup(name, type); - if (answer != null) { - break; - } } catch (Throwable e) { // do not double wrap the exception if (e instanceof NoSuchBeanException) { - throw (NoSuchBeanException) e; - } - throw new NoSuchBeanException(name, "Cannot lookup: " + name + " from registry: " + registry + ex = (NoSuchBeanException)e; + } else { + ex = new NoSuchBeanException(name, "Cannot lookup: " + name + " from registry: " + registry + " with expected type: " + type + " due: " + e.getMessage(), e); + } + } + if (answer != null) { + return answer; } } - return answer; + if (ex != null) { + throw ex; + } else { + return answer; + } } public Object lookup(String name) {