Author: ningjiang
Date: Thu Mar  7 08:43:42 2013
New Revision: 1453733

URL: http://svn.apache.org/r1453733
Log:
CAMEL-6135 CompositeRegistry should catch the exception when it lookup the 
component across the registries
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.10.x/camel-core/src/test/java/org/apache/camel/impl/CompositeRegistryTest.java
      - copied unchanged from r1453704, 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CompositeRegistryTest.java
Modified:
    camel/branches/camel-2.10.x/   (props changed)
    
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java
    camel/branches/camel-2.10.x/components/camel-jms/   (props changed)

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1453704

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java?rev=1453733&r1=1453732&r2=1453733&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java
 (original)
+++ 
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java
 Thu Mar  7 08:43:42 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> T lookup(String name, Class<T> 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) {

Propchange: camel/branches/camel-2.10.x/components/camel-jms/
------------------------------------------------------------------------------
  Merged /camel/trunk/components/camel-jms:r1453704


Reply via email to