{"action":"created","comment":{"url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/comments/103797952","pull_request_review_id":24599040,"id":103797952,"diff_hunk":"@@ -60,8 +60,13 @@ protected void configure(@Nullable final UUID kbTenantId) {\n     public C getConfigurable(@Nullable final UUID kbTenantId) {\n         // Initial configuration\n         if (kbTenantId != null && !configuredTenants.contains(kbTenantId)) {\n-            configure(kbTenantId);\n-            configuredTenants.add(kbTenantId);\n+            // Make sure to initialize the value for the tenant once\n+            synchronized (configuredTenants) {","path":"src/main/java/org/killbill/billing/plugin/api/notification/PluginTenantConfigurableConfigurationHandler.java","position":7,"original_position":7,"commit_id":"0fb8716e4322b3cafa24058feef121054e12f5ba","original_commit_id":"0fb8716e4322b3cafa24058feef121054e12f5ba","user":{"login":"andrenpaes","id":306982,"avatar_url":"https://avatars2.githubusercontent.com/u/306982?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenpaes","html_url":"https://github.com/andrenpaes","followers_url":"https://api.github.com/users/andrenpaes/followers","following_url":"https://api.github.com/users/andrenpaes/following{/other_user}","gists_url":"https://api.github.com/users/andrenpaes/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenpaes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenpaes/subscriptions","organizations_url":"https://api.github.com/users/andrenpaes/orgs","repos_url":"https://api.github.com/users/andrenpaes/repos","events_url":"https://api.github.com/users/andrenpaes/events{/privacy}","received_events_url":"https://api.github.com/users/andrenpaes/received_events","type":"User","site_admin":false},"body":"I wonder how much contention this would add, since this method is used pretty often (multiple times per request, right?).\r\nMaybe we could try the double check pattern here?\r\n```java\r\n    if (!configuredTenants.contains(kbTenantId)) {\r\n        synchronized (configuredTenants) {\r\n            if (!configuredTenants.contains(kbTenantId)) {\r\n                ...\r\n```\r\nI've seen ways that claim this pattern works, but it usually for instantiating a singleton `volatile` object. No idea if it would actually work for inserting on a Set.","created_at":"2017-03-01T21:49:25Z","updated_at":"2017-03-01T21:49:25Z","html_url":"https://github.com/killbill/killbill-plugin-framework-java/pull/10#discussion_r103797952","pull_request_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/comments/103797952"},"html":{"href":"https://github.com/killbill/killbill-plugin-framework-java/pull/10#discussion_r103797952"},"pull_request":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10","id":108505975,"html_url":"https://github.com/killbill/killbill-plugin-framework-java/pull/10","diff_url":"https://github.com/killbill/killbill-plugin-framework-java/pull/10.diff","patch_url":"https://github.com/killbill/killbill-plugin-framework-java/pull/10.patch","issue_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/10","number":10,"state":"open","locked":false,"title":"notification: make PluginTenantConfigurableConfigurationHandler#getConfigurable thread-safe","user":{"login":"pierre","id":51940,"avatar_url":"https://avatars1.githubusercontent.com/u/51940?v=3","gravatar_id":"","url":"https://api.github.com/users/pierre","html_url":"https://github.com/pierre","followers_url":"https://api.github.com/users/pierre/followers","following_url":"https://api.github.com/users/pierre/following{/other_user}","gists_url":"https://api.github.com/users/pierre/gists{/gist_id}","starred_url":"https://api.github.com/users/pierre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierre/subscriptions","organizations_url":"https://api.github.com/users/pierre/orgs","repos_url":"https://api.github.com/users/pierre/repos","events_url":"https://api.github.com/users/pierre/events{/privacy}","received_events_url":"https://api.github.com/users/pierre/received_events","type":"User","site_admin":false},"body":"Under high load upon startup, getConfigurable was initializing the configuration for a tenant multiple times. While the underlying map perTenantConfigurable is thread-safe, createConfigurable was called by concurrent threads unnecessarily and the value re-initialized.\r\n\r\nThis could cause unexpected behaviors because when the old value is replaced, close() is called on the configuration object while some threads might already been using it (note that this could still happen when updating a configuration live, but this should be infrequent).\r\n\r\n/cc @andrenpaes ","created_at":"2017-03-01T10:15:21Z","updated_at":"2017-03-01T21:49:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54e592f0b21108c4e722ac309e0c176d76d7fcaf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10/commits","review_comments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10/comments","review_comment_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/10/comments","statuses_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/statuses/0fb8716e4322b3cafa24058feef121054e12f5ba","head":{"label":"killbill:threadsafe-config","ref":"threadsafe-config","sha":"0fb8716e4322b3cafa24058feef121054e12f5ba","user":{"login":"killbill","id":2446739,"avatar_url":"https://avatars1.githubusercontent.com/u/2446739?v=3","gravatar_id":"","url":"https://api.github.com/users/killbill","html_url":"https://github.com/killbill","followers_url":"https://api.github.com/users/killbill/followers","following_url":"https://api.github.com/users/killbill/following{/other_user}","gists_url":"https://api.github.com/users/killbill/gists{/gist_id}","starred_url":"https://api.github.com/users/killbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killbill/subscriptions","organizations_url":"https://api.github.com/users/killbill/orgs","repos_url":"https://api.github.com/users/killbill/repos","events_url":"https://api.github.com/users/killbill/events{/privacy}","received_events_url":"https://api.github.com/users/killbill/received_events","type":"Organization","site_admin":false},"repo":{"id":27782564,"name":"killbill-plugin-framework-java","full_name":"killbill/killbill-plugin-framework-java","owner":{"login":"killbill","id":2446739,"avatar_url":"https://avatars1.githubusercontent.com/u/2446739?v=3","gravatar_id":"","url":"https://api.github.com/users/killbill","html_url":"https://github.com/killbill","followers_url":"https://api.github.com/users/killbill/followers","following_url":"https://api.github.com/users/killbill/following{/other_user}","gists_url":"https://api.github.com/users/killbill/gists{/gist_id}","starred_url":"https://api.github.com/users/killbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killbill/subscriptions","organizations_url":"https://api.github.com/users/killbill/orgs","repos_url":"https://api.github.com/users/killbill/repos","events_url":"https://api.github.com/users/killbill/events{/privacy}","received_events_url":"https://api.github.com/users/killbill/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/killbill/killbill-plugin-framework-java","description":"Framework to write Kill Bill plugins in Java","fork":false,"url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java","forks_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/forks","keys_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/teams","hooks_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/hooks","issue_events_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/events{/number}","events_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/events","assignees_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/assignees{/user}","branches_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/branches{/branch}","tags_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/tags","blobs_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/statuses/{sha}","languages_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/languages","stargazers_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/stargazers","contributors_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/contributors","subscribers_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/subscribers","subscription_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/subscription","commits_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/contents/{+path}","compare_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/merges","archive_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/downloads","issues_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues{/number}","pulls_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls{/number}","milestones_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/milestones{/number}","notifications_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/labels{/name}","releases_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/releases{/id}","deployments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/deployments","created_at":"2014-12-09T19:17:15Z","updated_at":"2016-11-13T20:46:55Z","pushed_at":"2017-03-01T10:15:22Z","git_url":"git://github.com/killbill/killbill-plugin-framework-java.git","ssh_url":"git@github.com:killbill/killbill-plugin-framework-java.git","clone_url":"https://github.com/killbill/killbill-plugin-framework-java.git","svn_url":"https://github.com/killbill/killbill-plugin-framework-java","homepage":"http://killbill.io","size":189,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"killbill:master","ref":"master","sha":"f250b111b278f549446d86ffccc6ca214a60c760","user":{"login":"killbill","id":2446739,"avatar_url":"https://avatars1.githubusercontent.com/u/2446739?v=3","gravatar_id":"","url":"https://api.github.com/users/killbill","html_url":"https://github.com/killbill","followers_url":"https://api.github.com/users/killbill/followers","following_url":"https://api.github.com/users/killbill/following{/other_user}","gists_url":"https://api.github.com/users/killbill/gists{/gist_id}","starred_url":"https://api.github.com/users/killbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killbill/subscriptions","organizations_url":"https://api.github.com/users/killbill/orgs","repos_url":"https://api.github.com/users/killbill/repos","events_url":"https://api.github.com/users/killbill/events{/privacy}","received_events_url":"https://api.github.com/users/killbill/received_events","type":"Organization","site_admin":false},"repo":{"id":27782564,"name":"killbill-plugin-framework-java","full_name":"killbill/killbill-plugin-framework-java","owner":{"login":"killbill","id":2446739,"avatar_url":"https://avatars1.githubusercontent.com/u/2446739?v=3","gravatar_id":"","url":"https://api.github.com/users/killbill","html_url":"https://github.com/killbill","followers_url":"https://api.github.com/users/killbill/followers","following_url":"https://api.github.com/users/killbill/following{/other_user}","gists_url":"https://api.github.com/users/killbill/gists{/gist_id}","starred_url":"https://api.github.com/users/killbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killbill/subscriptions","organizations_url":"https://api.github.com/users/killbill/orgs","repos_url":"https://api.github.com/users/killbill/repos","events_url":"https://api.github.com/users/killbill/events{/privacy}","received_events_url":"https://api.github.com/users/killbill/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/killbill/killbill-plugin-framework-java","description":"Framework to write Kill Bill plugins in Java","fork":false,"url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java","forks_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/forks","keys_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/teams","hooks_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/hooks","issue_events_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/events{/number}","events_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/events","assignees_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/assignees{/user}","branches_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/branches{/branch}","tags_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/tags","blobs_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/statuses/{sha}","languages_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/languages","stargazers_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/stargazers","contributors_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/contributors","subscribers_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/subscribers","subscription_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/subscription","commits_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/contents/{+path}","compare_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/merges","archive_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/downloads","issues_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues{/number}","pulls_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls{/number}","milestones_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/milestones{/number}","notifications_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/labels{/name}","releases_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/releases{/id}","deployments_url":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/deployments","created_at":"2014-12-09T19:17:15Z","updated_at":"2016-11-13T20:46:55Z","pushed_at":"2017-03-01T10:15:22Z","git_url":"git://github.com/killbill/killbill-plugin-framework-java.git","ssh_url":"git@github.com:killbill/killbill-plugin-framework-java.git","clone_url":"https://github.com/killbill/killbill-plugin-framework-java.git","svn_url":"https://github.com/killbill/killbill-plugin-framework-java","homepage":"http://killbill.io","size":189,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10"},"html":{"href":"https://github.com/killbill/killbill-plugin-framework-java/pull/10"},"issue":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/10"},"comments":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/killbill/killbill-plugin-framework-java/statuses/0fb8716e4322b3cafa24058feef121054e12f5ba"}}}}
{"actor":{"display_login":"andrenpaes"}}