{"action":"created","comment":{"url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments/165688918","pull_request_review_id":93665588,"id":165688918,"diff_hunk":"@@ -1627,25 +1627,23 @@ private Message doSendAndReceiveWithDirect(String exchange, String routingKey, M\n \t\tif (this.usePublisherConnection && connectionFactory.getPublisherConnectionFactory() != null) {\n \t\t\tconnectionFactory = connectionFactory.getPublisherConnectionFactory();\n \t\t}\n-\t\tDirectReplyToMessageListenerContainer container = this.directReplyToContainers.get(connectionFactory);\n-\t\tif (container == null) {\n-\t\t\tsynchronized (this.directReplyToContainers) {\n-\t\t\t\tcontainer = this.directReplyToContainers.get(connectionFactory);\n-\t\t\t\tif (container == null) {\n-\t\t\t\t\tcontainer = new DirectReplyToMessageListenerContainer(connectionFactory);\n-\t\t\t\t\tcontainer.setMessageListener(this);\n-\t\t\t\t\tcontainer.setBeanName(this.beanName + \"#\" + this.containerInstance.getAndIncrement());\n-\t\t\t\t\tif (this.taskExecutor != null) {\n-\t\t\t\t\t\tcontainer.setTaskExecutor(this.taskExecutor);\n-\t\t\t\t\t}\n-\t\t\t\t\tif (this.afterReceivePostProcessors != null) {\n-\t\t\t\t\t\tcontainer.setAfterReceivePostProcessors(this.afterReceivePostProcessors\n-\t\t\t\t\t\t\t\t.toArray(new MessagePostProcessor[this.afterReceivePostProcessors.size()]));\n-\t\t\t\t\t}\n-\t\t\t\t\tcontainer.start();\n-\t\t\t\t\tthis.directReplyToContainers.put(connectionFactory, container);\n-\t\t\t\t\tthis.replyAddress = Address.AMQ_RABBITMQ_REPLY_TO;\n+\t\tDirectReplyToMessageListenerContainer container;","path":"spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java","position":203,"original_position":22,"commit_id":"f3273b14af72696e568029827d468194932453ab","original_commit_id":"489df246b21268f1f15b134ab16b4d0b27b48334","user":{"login":"artembilan","id":1071590,"avatar_url":"https://avatars3.githubusercontent.com/u/1071590?v=4","gravatar_id":"","url":"https://api.github.com/users/artembilan","html_url":"https://github.com/artembilan","followers_url":"https://api.github.com/users/artembilan/followers","following_url":"https://api.github.com/users/artembilan/following{/other_user}","gists_url":"https://api.github.com/users/artembilan/gists{/gist_id}","starred_url":"https://api.github.com/users/artembilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artembilan/subscriptions","organizations_url":"https://api.github.com/users/artembilan/orgs","repos_url":"https://api.github.com/users/artembilan/repos","events_url":"https://api.github.com/users/artembilan/events{/privacy}","received_events_url":"https://api.github.com/users/artembilan/received_events","type":"User","site_admin":false},"body":"Would you mind explaining why this change, please?\r\n\r\nThe idea is like try to get `container` from the map concurrently without any locks.\r\nAnd only if it is null, go to the `synchronized (this.directReplyToContainers)` and try to do that again.\r\n\r\nBut now, with your, change we always block all other threads because the first one has decided to go to the `synchronized (this.directReplyToContainers)` block. The problem is going to be exponential for all the waiting threads and actually for nothing, if we have already populated `container` before.\r\n\r\nWe borrowed this style from the Singleton Pattern implementation: https://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples#thread-safe-singleton. This is called \"double checked locking principle is used\".\r\n\r\nWhat is idea do not do that?\r\n\r\nThanks","created_at":"2018-02-02T16:16:46Z","updated_at":"2018-02-02T16:21:55Z","html_url":"https://github.com/spring-projects/spring-amqp/pull/707#discussion_r165688918","pull_request_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments/165688918"},"html":{"href":"https://github.com/spring-projects/spring-amqp/pull/707#discussion_r165688918"},"pull_request":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707"}}},"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707","id":166793539,"html_url":"https://github.com/spring-projects/spring-amqp/pull/707","diff_url":"https://github.com/spring-projects/spring-amqp/pull/707.diff","patch_url":"https://github.com/spring-projects/spring-amqp/pull/707.patch","issue_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/707","number":707,"state":"open","locked":false,"title":"Improve rabbit template","user":{"login":"marknorkin","id":7955355,"avatar_url":"https://avatars3.githubusercontent.com/u/7955355?v=4","gravatar_id":"","url":"https://api.github.com/users/marknorkin","html_url":"https://github.com/marknorkin","followers_url":"https://api.github.com/users/marknorkin/followers","following_url":"https://api.github.com/users/marknorkin/following{/other_user}","gists_url":"https://api.github.com/users/marknorkin/gists{/gist_id}","starred_url":"https://api.github.com/users/marknorkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marknorkin/subscriptions","organizations_url":"https://api.github.com/users/marknorkin/orgs","repos_url":"https://api.github.com/users/marknorkin/repos","events_url":"https://api.github.com/users/marknorkin/events{/privacy}","received_events_url":"https://api.github.com/users/marknorkin/received_events","type":"User","site_admin":false},"body":"Hello, Gary and Artem\r\n\r\nPlease take a look at several small improvements to rabbit template.\r\nYou can find explanation for each change in commit messages.\r\n\r\nHappy to resolve any comments if you find this PR useful.\r\n","created_at":"2018-02-02T12:44:14Z","updated_at":"2018-02-02T16:21:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1524adc7d0b00d510da8f46a0e3b18a173b7d6aa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707/commits","review_comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707/comments","review_comment_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/707/comments","statuses_url":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/f3273b14af72696e568029827d468194932453ab","head":{"label":"marknorkin:improve-rabbit-template","ref":"improve-rabbit-template","sha":"f3273b14af72696e568029827d468194932453ab","user":{"login":"marknorkin","id":7955355,"avatar_url":"https://avatars3.githubusercontent.com/u/7955355?v=4","gravatar_id":"","url":"https://api.github.com/users/marknorkin","html_url":"https://github.com/marknorkin","followers_url":"https://api.github.com/users/marknorkin/followers","following_url":"https://api.github.com/users/marknorkin/following{/other_user}","gists_url":"https://api.github.com/users/marknorkin/gists{/gist_id}","starred_url":"https://api.github.com/users/marknorkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marknorkin/subscriptions","organizations_url":"https://api.github.com/users/marknorkin/orgs","repos_url":"https://api.github.com/users/marknorkin/repos","events_url":"https://api.github.com/users/marknorkin/events{/privacy}","received_events_url":"https://api.github.com/users/marknorkin/received_events","type":"User","site_admin":false},"repo":{"id":119873420,"name":"spring-amqp","full_name":"marknorkin/spring-amqp","owner":{"login":"marknorkin","id":7955355,"avatar_url":"https://avatars3.githubusercontent.com/u/7955355?v=4","gravatar_id":"","url":"https://api.github.com/users/marknorkin","html_url":"https://github.com/marknorkin","followers_url":"https://api.github.com/users/marknorkin/followers","following_url":"https://api.github.com/users/marknorkin/following{/other_user}","gists_url":"https://api.github.com/users/marknorkin/gists{/gist_id}","starred_url":"https://api.github.com/users/marknorkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marknorkin/subscriptions","organizations_url":"https://api.github.com/users/marknorkin/orgs","repos_url":"https://api.github.com/users/marknorkin/repos","events_url":"https://api.github.com/users/marknorkin/events{/privacy}","received_events_url":"https://api.github.com/users/marknorkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marknorkin/spring-amqp","description":"Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ","fork":true,"url":"https://api.github.com/repos/marknorkin/spring-amqp","forks_url":"https://api.github.com/repos/marknorkin/spring-amqp/forks","keys_url":"https://api.github.com/repos/marknorkin/spring-amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marknorkin/spring-amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marknorkin/spring-amqp/teams","hooks_url":"https://api.github.com/repos/marknorkin/spring-amqp/hooks","issue_events_url":"https://api.github.com/repos/marknorkin/spring-amqp/issues/events{/number}","events_url":"https://api.github.com/repos/marknorkin/spring-amqp/events","assignees_url":"https://api.github.com/repos/marknorkin/spring-amqp/assignees{/user}","branches_url":"https://api.github.com/repos/marknorkin/spring-amqp/branches{/branch}","tags_url":"https://api.github.com/repos/marknorkin/spring-amqp/tags","blobs_url":"https://api.github.com/repos/marknorkin/spring-amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marknorkin/spring-amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marknorkin/spring-amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/marknorkin/spring-amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marknorkin/spring-amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/marknorkin/spring-amqp/languages","stargazers_url":"https://api.github.com/repos/marknorkin/spring-amqp/stargazers","contributors_url":"https://api.github.com/repos/marknorkin/spring-amqp/contributors","subscribers_url":"https://api.github.com/repos/marknorkin/spring-amqp/subscribers","subscription_url":"https://api.github.com/repos/marknorkin/spring-amqp/subscription","commits_url":"https://api.github.com/repos/marknorkin/spring-amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/marknorkin/spring-amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/marknorkin/spring-amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/marknorkin/spring-amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/marknorkin/spring-amqp/contents/{+path}","compare_url":"https://api.github.com/repos/marknorkin/spring-amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marknorkin/spring-amqp/merges","archive_url":"https://api.github.com/repos/marknorkin/spring-amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marknorkin/spring-amqp/downloads","issues_url":"https://api.github.com/repos/marknorkin/spring-amqp/issues{/number}","pulls_url":"https://api.github.com/repos/marknorkin/spring-amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/marknorkin/spring-amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/marknorkin/spring-amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marknorkin/spring-amqp/labels{/name}","releases_url":"https://api.github.com/repos/marknorkin/spring-amqp/releases{/id}","deployments_url":"https://api.github.com/repos/marknorkin/spring-amqp/deployments","created_at":"2018-02-01T18:04:52Z","updated_at":"2018-02-01T18:04:55Z","pushed_at":"2018-02-02T11:16:24Z","git_url":"git://github.com/marknorkin/spring-amqp.git","ssh_url":"git@github.com:marknorkin/spring-amqp.git","clone_url":"https://github.com/marknorkin/spring-amqp.git","svn_url":"https://github.com/marknorkin/spring-amqp","homepage":"http://www.springsource.org/spring-amqp","size":9456,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"spring-projects:master","ref":"master","sha":"18b209040cd1c0e2ff06a95b3fd1f271d36b925b","user":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars0.githubusercontent.com/u/317776?v=4","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"repo":{"id":1088796,"name":"spring-amqp","full_name":"spring-projects/spring-amqp","owner":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars0.githubusercontent.com/u/317776?v=4","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spring-projects/spring-amqp","description":"Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ","fork":false,"url":"https://api.github.com/repos/spring-projects/spring-amqp","forks_url":"https://api.github.com/repos/spring-projects/spring-amqp/forks","keys_url":"https://api.github.com/repos/spring-projects/spring-amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spring-projects/spring-amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spring-projects/spring-amqp/teams","hooks_url":"https://api.github.com/repos/spring-projects/spring-amqp/hooks","issue_events_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/events{/number}","events_url":"https://api.github.com/repos/spring-projects/spring-amqp/events","assignees_url":"https://api.github.com/repos/spring-projects/spring-amqp/assignees{/user}","branches_url":"https://api.github.com/repos/spring-projects/spring-amqp/branches{/branch}","tags_url":"https://api.github.com/repos/spring-projects/spring-amqp/tags","blobs_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/spring-projects/spring-amqp/languages","stargazers_url":"https://api.github.com/repos/spring-projects/spring-amqp/stargazers","contributors_url":"https://api.github.com/repos/spring-projects/spring-amqp/contributors","subscribers_url":"https://api.github.com/repos/spring-projects/spring-amqp/subscribers","subscription_url":"https://api.github.com/repos/spring-projects/spring-amqp/subscription","commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/spring-projects/spring-amqp/contents/{+path}","compare_url":"https://api.github.com/repos/spring-projects/spring-amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spring-projects/spring-amqp/merges","archive_url":"https://api.github.com/repos/spring-projects/spring-amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spring-projects/spring-amqp/downloads","issues_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues{/number}","pulls_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/spring-projects/spring-amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/spring-projects/spring-amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spring-projects/spring-amqp/labels{/name}","releases_url":"https://api.github.com/repos/spring-projects/spring-amqp/releases{/id}","deployments_url":"https://api.github.com/repos/spring-projects/spring-amqp/deployments","created_at":"2010-11-17T15:50:16Z","updated_at":"2018-01-31T12:51:41Z","pushed_at":"2018-02-02T12:44:15Z","git_url":"git://github.com/spring-projects/spring-amqp.git","ssh_url":"git@github.com:spring-projects/spring-amqp.git","clone_url":"https://github.com/spring-projects/spring-amqp.git","svn_url":"https://github.com/spring-projects/spring-amqp","homepage":"http://www.springsource.org/spring-amqp","size":9448,"stargazers_count":374,"watchers_count":374,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":328,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":328,"open_issues":2,"watchers":374,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707"},"html":{"href":"https://github.com/spring-projects/spring-amqp/pull/707"},"issue":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/issues/707"},"comments":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/issues/707/comments"},"review_comments":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707/comments"},"review_comment":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/707/commits"},"statuses":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/f3273b14af72696e568029827d468194932453ab"}},"author_association":"NONE"}}
{"actor":{"display_login":"artembilan"}}