mirror of https://github.com/apache/activemq.git
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:
parent
538b23bdeb
commit
5dde5562a9
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue