Skip to content

Commit

Permalink
Access directReplyToContainers map only via lock
Browse files Browse the repository at this point in the history
remove double checking for null container
  • Loading branch information
marknorkin committed Feb 2, 2018
1 parent 63e685a commit 489df24
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1627,25 +1627,23 @@ private Message doSendAndReceiveWithDirect(String exchange, String routingKey, M
if (this.usePublisherConnection && connectionFactory.getPublisherConnectionFactory() != null) {
connectionFactory = connectionFactory.getPublisherConnectionFactory();
}
DirectReplyToMessageListenerContainer container = this.directReplyToContainers.get(connectionFactory);
if (container == null) {
synchronized (this.directReplyToContainers) {
container = this.directReplyToContainers.get(connectionFactory);
if (container == null) {
container = new DirectReplyToMessageListenerContainer(connectionFactory);
container.setMessageListener(this);
container.setBeanName(this.beanName + "#" + this.containerInstance.getAndIncrement());
if (this.taskExecutor != null) {
container.setTaskExecutor(this.taskExecutor);
}
if (this.afterReceivePostProcessors != null) {
container.setAfterReceivePostProcessors(this.afterReceivePostProcessors
.toArray(new MessagePostProcessor[this.afterReceivePostProcessors.size()]));
}
container.start();
this.directReplyToContainers.put(connectionFactory, container);
this.replyAddress = Address.AMQ_RABBITMQ_REPLY_TO;
DirectReplyToMessageListenerContainer container;
synchronized (this.directReplyToContainers) {
container = this.directReplyToContainers.get(connectionFactory);
if (container == null) {
container = new DirectReplyToMessageListenerContainer(connectionFactory);
container.setMessageListener(this);
container.setBeanName(this.beanName + "#" + this.containerInstance.getAndIncrement());
if (this.taskExecutor != null) {
container.setTaskExecutor(this.taskExecutor);
}
if (this.afterReceivePostProcessors != null) {
container.setAfterReceivePostProcessors(this.afterReceivePostProcessors
.toArray(new MessagePostProcessor[this.afterReceivePostProcessors.size()]));
}
container.start();
this.directReplyToContainers.put(connectionFactory, container);
this.replyAddress = Address.AMQ_RABBITMQ_REPLY_TO;
}
}
ChannelHolder channelHolder = container.getChannelHolder();
Expand Down

0 comments on commit 489df24

Please sign in to comment.