Avoid unnecessary connection state lookup leading to lock ordering
issues.
(cherry picked from commit 98d2000833)
This commit is contained in:
Timothy Bish 2016-06-09 12:09:42 -04:00
parent 539d6b747a
commit d594248db5
1 changed files with 4 additions and 5 deletions

View File

@ -671,7 +671,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
broker.addConsumer(cs.getContext(), info);
try {
ss.addConsumer(info);
addConsumerBrokerExchange(info.getConsumerId());
addConsumerBrokerExchange(cs, info.getConsumerId());
} catch (IllegalStateException e) {
broker.removeConsumer(cs.getContext(), info);
}
@ -1513,15 +1513,14 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
return result;
}
private ConsumerBrokerExchange addConsumerBrokerExchange(ConsumerId id) {
private ConsumerBrokerExchange addConsumerBrokerExchange(TransportConnectionState connectionState, ConsumerId id) {
ConsumerBrokerExchange result = consumerExchanges.get(id);
if (result == null) {
synchronized (consumerExchanges) {
result = new ConsumerBrokerExchange();
TransportConnectionState state = lookupConnectionState(id);
context = state.getContext();
context = connectionState.getContext();
result.setConnectionContext(context);
SessionState ss = state.getSessionState(id.getParentId());
SessionState ss = connectionState.getSessionState(id.getParentId());
if (ss != null) {
ConsumerState cs = ss.getConsumerState(id);
if (cs != null) {