camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
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 GMT
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> 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) {



Mime
View raw message