camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: Optimize the toString of endpoint
Date Fri, 12 Feb 2016 16:55:01 GMT
Optimize the toString of endpoint


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

Branch: refs/heads/master
Commit: fffafeb9f429b7e3a69f47d427d03a8f9344f84d
Parents: f35ed71
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Feb 12 16:03:01 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Feb 12 17:54:51 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/impl/DefaultEndpoint.java | 16 ++++++++++------
 .../main/java/org/apache/camel/util/URISupport.java |  2 +-
 .../org/apache/camel/impl/DefaultEndpointTest.java  |  1 -
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fffafeb9/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 cf6461e..ff8253c 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
@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory;
 public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint, HasId,
CamelContextAware {
 
     private static final Logger LOG = LoggerFactory.getLogger(DefaultEndpoint.class);
+    private transient String endpointUriToString;
     private String endpointUri;
     private EndpointConfiguration endpointConfiguration;
     private CamelContext camelContext;
@@ -153,13 +154,16 @@ public abstract class DefaultEndpoint extends ServiceSupport implements
Endpoint
 
     @Override
     public String toString() {
-        String value = null;
-        try {
-            value = getEndpointUri();
-        } catch (RuntimeException e) {
-            // ignore any exception and use null for building the string value
+        if (endpointUriToString == null) {
+            String value = null;
+            try {
+                value = getEndpointUri();
+            } catch (RuntimeException e) {
+                // ignore any exception and use null for building the string value
+            }
+            endpointUriToString = String.format("Endpoint[%s]", URISupport.sanitizeUri(value));
         }
-        return String.format("Endpoint[%s]", URISupport.sanitizeUri(value));
+        return endpointUriToString;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/fffafeb9/camel-core/src/main/java/org/apache/camel/util/URISupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
index 90229a6..20dd1c2 100644
--- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
@@ -63,7 +63,7 @@ public final class URISupport {
      * Removes detected sensitive information (such as passwords) from the URI and returns
the result.
      *
      * @param uri The uri to sanitize.
-     * @see #SECRETS for the matched pattern
+     * @see #SECRETS and #USERINFO_PASSWORD for the matched pattern
      *
      * @return Returns null if the uri is null, otherwise the URI with the passphrase, password
or secretKey sanitized.
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/fffafeb9/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 0b61ef7..9a2f657 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
@@ -45,7 +45,6 @@ public class DefaultEndpointTest extends ContextTestSupport {
     public void testToString() {
         final String epstr = "myep:///test";
         MyEndpoint ep = new MyEndpoint();
-        assertNotNull(ep.toString());
         ep.setEndpointUri(epstr);
         assertTrue(ep.toString().indexOf(epstr) > 0);
     }


Mime
View raw message