Use a latch so that the getBrokerName() call is moreforgiving of connection establishment timing issues.

git-svn-id: https://svn.apache.org/repos/asf/activemq/branches/activemq-4.1@524779 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-04-02 13:39:40 +00:00
parent 538b23bdeb
commit 5dde5562a9
1 changed files with 10 additions and 4 deletions

View File

@ -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;
}
}
/**