You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/11/19 15:20:58 UTC

[1/2] camel git commit: camel-cdi - Should not toString instance as its likely proxied in CDI and can cause to mask the real exception.

Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 07331a5a3 -> ec24b75c0
  refs/heads/master 95834c0eb -> 2683ed9b0


camel-cdi - Should not toString instance as its likely proxied in CDI and can cause to mask the real exception.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec24b75c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec24b75c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec24b75c

Branch: refs/heads/camel-2.15.x
Commit: ec24b75c07a613cd54423c54730e656185bcb229
Parents: 07331a5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Nov 19 15:19:39 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Nov 19 15:20:21 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/cdi/internal/CamelContextConfig.java    | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ec24b75c/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
index 523d41d..65c92ac 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
@@ -63,8 +63,9 @@ public class CamelContextConfig {
                 }
             }
             Object reference = beanManager.getReference(bean, beanClass, createContext);
-            ObjectHelper.notNull(reference, "Could not instantiate bean of type " + beanClass.getName() + " for " + bean);
+            ObjectHelper.notNull(reference, "Could not instantiate bean of type: " + beanClass.getName() + " for " + bean);
             try {
+                // we should not toString reference instance as in CDI it may be proxied
                 if (reference instanceof RoutesBuilder) {
                     RoutesBuilder routeBuilder = (RoutesBuilder)reference;
                     camelContext.addRoutes(routeBuilder);
@@ -72,14 +73,12 @@ public class CamelContextConfig {
                     RouteContainer routeContainer = (RouteContainer)reference;
                     camelContext.addRouteDefinitions(routeContainer.getRoutes());
                 } else {
-                    throw new IllegalArgumentException("Invalid route builder " + reference
-                            + " of type " + beanClass.getName()
+                    throw new IllegalArgumentException("Invalid route builder of type: " + beanClass.getName()
                             + ". Should be RoutesBuilder or RoutesContainer");
                 }
             } catch (Exception e) {
-                throw new RuntimeCamelException(
-                        "Could not add " + reference + " to CamelContext: " + camelContext + ". Reason: " + e,
-                        e);
+                throw new RuntimeCamelException("Error adding route builder of type: " + beanClass.getName()
+                        + " to CamelContext: " + camelContext.getName() + " due " + e.getMessage(), e);
             }
         }
     }


[2/2] camel git commit: camel-cdi - Should not toString instance as its likely proxied in CDI and can cause to mask the real exception.

Posted by da...@apache.org.
camel-cdi - Should not toString instance as its likely proxied in CDI and can cause to mask the real exception.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2683ed9b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2683ed9b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2683ed9b

Branch: refs/heads/master
Commit: 2683ed9b024b7e5da64e5ffc2891be15acc48ded
Parents: 95834c0
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Nov 19 15:19:39 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Nov 19 15:20:50 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/cdi/internal/CamelContextConfig.java    | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2683ed9b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
index 523d41d..65c92ac 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
@@ -63,8 +63,9 @@ public class CamelContextConfig {
                 }
             }
             Object reference = beanManager.getReference(bean, beanClass, createContext);
-            ObjectHelper.notNull(reference, "Could not instantiate bean of type " + beanClass.getName() + " for " + bean);
+            ObjectHelper.notNull(reference, "Could not instantiate bean of type: " + beanClass.getName() + " for " + bean);
             try {
+                // we should not toString reference instance as in CDI it may be proxied
                 if (reference instanceof RoutesBuilder) {
                     RoutesBuilder routeBuilder = (RoutesBuilder)reference;
                     camelContext.addRoutes(routeBuilder);
@@ -72,14 +73,12 @@ public class CamelContextConfig {
                     RouteContainer routeContainer = (RouteContainer)reference;
                     camelContext.addRouteDefinitions(routeContainer.getRoutes());
                 } else {
-                    throw new IllegalArgumentException("Invalid route builder " + reference
-                            + " of type " + beanClass.getName()
+                    throw new IllegalArgumentException("Invalid route builder of type: " + beanClass.getName()
                             + ". Should be RoutesBuilder or RoutesContainer");
                 }
             } catch (Exception e) {
-                throw new RuntimeCamelException(
-                        "Could not add " + reference + " to CamelContext: " + camelContext + ". Reason: " + e,
-                        e);
+                throw new RuntimeCamelException("Error adding route builder of type: " + beanClass.getName()
+                        + " to CamelContext: " + camelContext.getName() + " due " + e.getMessage(), e);
             }
         }
     }