camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: CAMEL-7344: Some endpoints configured using beans may result in NPE under DEBUG mode
Date Mon, 07 Apr 2014 12:47:28 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 38391554e -> a124f8de5


CAMEL-7344: Some endpoints configured using beans may result in NPE under DEBUG mode


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

Branch: refs/heads/camel-2.13.x
Commit: a124f8de586da5f70a40b4bdc7548c255d48e175
Parents: 3839155
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Mon Apr 7 14:42:35 2014 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Mon Apr 7 14:45:17 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultEndpoint.java  |  8 +++++-
 .../apache/camel/impl/DefaultEndpointTest.java  | 27 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a124f8de/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
index 3dae289..badd48e 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
@@ -136,7 +136,13 @@ public abstract class DefaultEndpoint extends ServiceSupport implements
Endpoint
 
     @Override
     public String toString() {
-        return String.format("Endpoint[%s]", URISupport.sanitizeUri(getEndpointUri()));
+        String value = null;
+        try {
+            value = getEndpointUri();
+        } catch (RuntimeException e) {
+            // ignore any exception and use null for building the string value
+        }
+        return String.format("Endpoint[%s]", URISupport.sanitizeUri(value));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/a124f8de/camel-core/src/test/java/org/apache/camel/impl/DefaultEndpointTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultEndpointTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultEndpointTest.java
index 8104095..0b61ef7 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultEndpointTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultEndpointTest.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.impl;
 
+import org.apache.camel.Consumer;
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
 import org.apache.camel.util.URISupport;
 
 /**
@@ -39,6 +42,14 @@ public class DefaultEndpointTest extends ContextTestSupport {
             URISupport.sanitizeUri("aws-sqs://MyQueue?accessKey=1672t4rflhnhli3&secretKey=qi472qfberu33dqjncq"));
     }
 
+    public void testToString() {
+        final String epstr = "myep:///test";
+        MyEndpoint ep = new MyEndpoint();
+        assertNotNull(ep.toString());
+        ep.setEndpointUri(epstr);
+        assertTrue(ep.toString().indexOf(epstr) > 0);
+    }
+
     /**
      * Ensures that the Uri was not changed because no password was found.
      *
@@ -48,4 +59,20 @@ public class DefaultEndpointTest extends ContextTestSupport {
         assertEquals(uri, URISupport.sanitizeUri(uri));
     }
 
+    private static class MyEndpoint extends DefaultEndpoint {
+        @Override
+        public Producer createProducer() throws Exception {
+            return null;
+        }
+
+        @Override
+        public Consumer createConsumer(Processor processor) throws Exception {
+            return null;
+        }
+
+        @Override
+        public boolean isSingleton() {
+            return false;
+        }
+    }
 }


Mime
View raw message