diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java index 4f3fcb3b3f..d4a2b49e19 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java @@ -1370,10 +1370,16 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon * Returns the broker name if one is available or null if one is not available yet. */ public String getBrokerName() { - if (brokerInfo == null) { - return null; - } - return brokerInfo.getBrokerName(); + try { + brokerInfoReceived.await(5,TimeUnit.SECONDS); + if (brokerInfo == null) { + return null; + } + return brokerInfo.getBrokerName(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return null; + } } /**