From e16114f99bdef263f3d79deacea32302f99cd9bf Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Fri, 1 Sep 2006 15:06:13 +0000 Subject: [PATCH] Protect against NPE when toString() is called before object is fully initialized. Spring seems to be doing this (part of of it's debug logging) with newer releases. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@439346 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/broker/TransportConnector.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java index fd3721caf6..30893688e8 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java @@ -310,7 +310,10 @@ public class TransportConnector implements Connector { public String getName(){ if( name==null ){ - name = getUri().toString(); + uri = getUri(); + if( uri != null ) { + name = uri.toString(); + } } return name; } @@ -319,7 +322,10 @@ public class TransportConnector implements Connector { } public String toString() { - return getName(); + String rc = getName(); + if( rc == null ) + rc = super.toString(); + return rc; } public boolean isDisableAsyncDispatch() {