{"action":"created","comment":{"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments/53237328","id":53237328,"diff_hunk":"@@ -50,79 +52,103 @@ public OpenShiftProjectCache() {\n \t}\n \t\n \t@Override\n-\tpublic synchronized Collection<IProjectAdapter> getProjectsFor(final IOpenShiftConnection conn) {\n+\tpublic Collection<IProjectAdapter> getProjectsFor(final IOpenShiftConnection conn) {\n \t\tString key = getCacheKey(conn);\n-\t\tif(!cache.containsKey(key)) {\n+\t\tSet<IProjectAdapter> adapters = null;\n+\t\tif (!contains(key)) {\n+\t\t\tadapters = createEntry(key);\n \t\t\tCollection<IProject> projects = conn.<IProject>getResources(ResourceKind.PROJECT);\n-\t\t\tSet<IProjectAdapter> adapters = new HashSet<>();\n \t\t\tfor (IProject project : projects) {\n-\t\t\t\tnewProjectAdapter(adapters, conn, project);\n+\t\t\t\tIProjectAdapter adapter = addNewProjectAdapter(adapters, conn, project);\n+\t\t\t\tnotifyAdd(adapter);\n \t\t\t}\n-\t\t\tcache.put(key, adapters);\n-\t\t\tnotifyAdd(adapters);\n+\t\t} else {\n+\t\t\tadapters = cache.get(key);\n \t\t}\n-\t\treturn new ArrayList<>(cache.get(key));\n+\n+\t\treturn new ArrayList<>(adapters);\n+\t}\n+\n+\tprivate boolean contains(String key) {\n+\t\treturn cache.containsKey(key);\n \t}\n-\t\n-\t\n \t\n \t@Override\n-\tpublic synchronized void flushFor(IOpenShiftConnection conn) {\n+\tpublic void flushFor(IOpenShiftConnection conn) {\n \t\tSet<IProjectAdapter> adapters = cache.remove(getCacheKey(conn));\n-\t\tif(adapters != null) {\n-\t\t\tnotifyRemove(adapters);\n+\t\tif (adapters != null) {\n+\t\t\tsynchronized(adapters) {\n+\t\t\t\tnotifyRemove(adapters);\n+\t\t\t}\n \t\t}\n \t}\n \n \t@SuppressWarnings(\"unchecked\")\n \t@Override\n-\tpublic synchronized void connectionChanged(IConnection connection, String property, Object oldValue, Object newValue) {\n+\tpublic void connectionChanged(IConnection connection, String property, Object oldValue, Object newValue) {\n \t\tif (!(connection instanceof IOpenShiftConnection)) {\n \t\t\treturn;\n \t\t}\n-\t\tif (ConnectionProperties.PROPERTY_PROJECTS.equals(property) && (oldValue instanceof List) && (newValue instanceof List)) {\n-\t\t\tList<IProject> newProjects = (List<IProject>) newValue;\n-\t\t\tList<IProject> oldProjects = (List<IProject>) oldValue;\n-\t\t\tIOpenShiftConnection conn = (IOpenShiftConnection)connection;\n-\t\t\tfinal String key = getCacheKey(conn);\n-\t\t\t\n-\t\t\tSet<IProjectAdapter> adapters = (Set<IProjectAdapter>) ObjectUtils.defaultIfNull(cache.get(key), new HashSet<>());\n-\t\t\tMap<IProject, IProjectAdapter> projectMap = adapters.stream().collect(Collectors.toMap(IProjectAdapter::getProject, Function.identity()));\n-\t\t\t\n+\t\tif (ConnectionProperties.PROPERTY_PROJECTS.equals(property) \n+\t\t\t\t&& (oldValue instanceof List)\n+\t\t\t\t&& (newValue instanceof List)) {\n+\t\t\tIOpenShiftConnection openshiftConnection = (IOpenShiftConnection) connection;\n+\t\t\tString key = getCacheKey(openshiftConnection);\n+\t\t\tSet<IProjectAdapter> adapters = getOrCreateEntry(key);\n+\t\t\taddAndRemoveAdaptersFor((List<IProject>) newValue, (List<IProject>) oldValue, openshiftConnection, adapters);\n+\t\t}\n+\t}\n+\n+\tprivate Set<IProjectAdapter> getOrCreateEntry(String key) {\n+\t\tSet<IProjectAdapter> adapters = cache.get(key);","path":"plugins/org.jboss.tools.openshift.ui/src/org/jboss/tools/openshift/internal/ui/models/OpenShiftProjectCache.java","position":107,"original_position":107,"commit_id":"28dc78e521ed56761958eef203aa169141c2555d","original_commit_id":"28dc78e521ed56761958eef203aa169141c2555d","user":{"login":"jcantrill","id":4548408,"avatar_url":"https://avatars.githubusercontent.com/u/4548408?v=3","gravatar_id":"","url":"https://api.github.com/users/jcantrill","html_url":"https://github.com/jcantrill","followers_url":"https://api.github.com/users/jcantrill/followers","following_url":"https://api.github.com/users/jcantrill/following{/other_user}","gists_url":"https://api.github.com/users/jcantrill/gists{/gist_id}","starred_url":"https://api.github.com/users/jcantrill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcantrill/subscriptions","organizations_url":"https://api.github.com/users/jcantrill/orgs","repos_url":"https://api.github.com/users/jcantrill/repos","events_url":"https://api.github.com/users/jcantrill/events{/privacy}","received_events_url":"https://api.github.com/users/jcantrill/received_events","type":"User","site_admin":false},"body":"Do we need to synchronize on the cache here so we dont have 2 threads trying to map to a key at the same time","created_at":"2016-02-17T21:53:49Z","updated_at":"2016-02-17T21:53:49Z","html_url":"https://github.com/jbosstools/jbosstools-openshift/pull/961#discussion_r53237328","pull_request_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961","_links":{"self":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments/53237328"},"html":{"href":"https://github.com/jbosstools/jbosstools-openshift/pull/961#discussion_r53237328"},"pull_request":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961"}}},"pull_request":{"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961","id":59711249,"html_url":"https://github.com/jbosstools/jbosstools-openshift/pull/961","diff_url":"https://github.com/jbosstools/jbosstools-openshift/pull/961.diff","patch_url":"https://github.com/jbosstools/jbosstools-openshift/pull/961.patch","issue_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/961","number":961,"state":"open","locked":false,"title":"[JBIDE-21686] reduced snchronized blocks to prevent deadlocks","user":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-17T21:25:22Z","updated_at":"2016-02-17T21:53:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c86ef3b9a505067a5af83459881ddde3c85deb9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961/commits","review_comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961/comments","review_comment_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/961/comments","statuses_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/28dc78e521ed56761958eef203aa169141c2555d","head":{"label":"adietish:JBIDE-21686","ref":"JBIDE-21686","sha":"28dc78e521ed56761958eef203aa169141c2555d","user":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"repo":{"id":6351407,"name":"jbosstools-openshift","full_name":"adietish/jbosstools-openshift","owner":{"login":"adietish","id":25126,"avatar_url":"https://avatars.githubusercontent.com/u/25126?v=3","gravatar_id":"","url":"https://api.github.com/users/adietish","html_url":"https://github.com/adietish","followers_url":"https://api.github.com/users/adietish/followers","following_url":"https://api.github.com/users/adietish/following{/other_user}","gists_url":"https://api.github.com/users/adietish/gists{/gist_id}","starred_url":"https://api.github.com/users/adietish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adietish/subscriptions","organizations_url":"https://api.github.com/users/adietish/orgs","repos_url":"https://api.github.com/users/adietish/repos","events_url":"https://api.github.com/users/adietish/events{/privacy}","received_events_url":"https://api.github.com/users/adietish/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adietish/jbosstools-openshift","description":"JBoss Tools :: OpenShift { openshift }","fork":true,"url":"https://api.github.com/repos/adietish/jbosstools-openshift","forks_url":"https://api.github.com/repos/adietish/jbosstools-openshift/forks","keys_url":"https://api.github.com/repos/adietish/jbosstools-openshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adietish/jbosstools-openshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adietish/jbosstools-openshift/teams","hooks_url":"https://api.github.com/repos/adietish/jbosstools-openshift/hooks","issue_events_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues/events{/number}","events_url":"https://api.github.com/repos/adietish/jbosstools-openshift/events","assignees_url":"https://api.github.com/repos/adietish/jbosstools-openshift/assignees{/user}","branches_url":"https://api.github.com/repos/adietish/jbosstools-openshift/branches{/branch}","tags_url":"https://api.github.com/repos/adietish/jbosstools-openshift/tags","blobs_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adietish/jbosstools-openshift/statuses/{sha}","languages_url":"https://api.github.com/repos/adietish/jbosstools-openshift/languages","stargazers_url":"https://api.github.com/repos/adietish/jbosstools-openshift/stargazers","contributors_url":"https://api.github.com/repos/adietish/jbosstools-openshift/contributors","subscribers_url":"https://api.github.com/repos/adietish/jbosstools-openshift/subscribers","subscription_url":"https://api.github.com/repos/adietish/jbosstools-openshift/subscription","commits_url":"https://api.github.com/repos/adietish/jbosstools-openshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/adietish/jbosstools-openshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/adietish/jbosstools-openshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/adietish/jbosstools-openshift/contents/{+path}","compare_url":"https://api.github.com/repos/adietish/jbosstools-openshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adietish/jbosstools-openshift/merges","archive_url":"https://api.github.com/repos/adietish/jbosstools-openshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adietish/jbosstools-openshift/downloads","issues_url":"https://api.github.com/repos/adietish/jbosstools-openshift/issues{/number}","pulls_url":"https://api.github.com/repos/adietish/jbosstools-openshift/pulls{/number}","milestones_url":"https://api.github.com/repos/adietish/jbosstools-openshift/milestones{/number}","notifications_url":"https://api.github.com/repos/adietish/jbosstools-openshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adietish/jbosstools-openshift/labels{/name}","releases_url":"https://api.github.com/repos/adietish/jbosstools-openshift/releases{/id}","deployments_url":"https://api.github.com/repos/adietish/jbosstools-openshift/deployments","created_at":"2012-10-23T11:48:16Z","updated_at":"2015-05-05T14:50:36Z","pushed_at":"2016-02-17T21:39:19Z","git_url":"git://github.com/adietish/jbosstools-openshift.git","ssh_url":"git@github.com:adietish/jbosstools-openshift.git","clone_url":"https://github.com/adietish/jbosstools-openshift.git","svn_url":"https://github.com/adietish/jbosstools-openshift","homepage":"","size":15228,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jbosstools:jbosstools-4.3.x","ref":"jbosstools-4.3.x","sha":"e265675017d5b80b1f372ac472cac3813768647b","user":{"login":"jbosstools","id":619871,"avatar_url":"https://avatars.githubusercontent.com/u/619871?v=3","gravatar_id":"","url":"https://api.github.com/users/jbosstools","html_url":"https://github.com/jbosstools","followers_url":"https://api.github.com/users/jbosstools/followers","following_url":"https://api.github.com/users/jbosstools/following{/other_user}","gists_url":"https://api.github.com/users/jbosstools/gists{/gist_id}","starred_url":"https://api.github.com/users/jbosstools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbosstools/subscriptions","organizations_url":"https://api.github.com/users/jbosstools/orgs","repos_url":"https://api.github.com/users/jbosstools/repos","events_url":"https://api.github.com/users/jbosstools/events{/privacy}","received_events_url":"https://api.github.com/users/jbosstools/received_events","type":"Organization","site_admin":false},"repo":{"id":6308288,"name":"jbosstools-openshift","full_name":"jbosstools/jbosstools-openshift","owner":{"login":"jbosstools","id":619871,"avatar_url":"https://avatars.githubusercontent.com/u/619871?v=3","gravatar_id":"","url":"https://api.github.com/users/jbosstools","html_url":"https://github.com/jbosstools","followers_url":"https://api.github.com/users/jbosstools/followers","following_url":"https://api.github.com/users/jbosstools/following{/other_user}","gists_url":"https://api.github.com/users/jbosstools/gists{/gist_id}","starred_url":"https://api.github.com/users/jbosstools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbosstools/subscriptions","organizations_url":"https://api.github.com/users/jbosstools/orgs","repos_url":"https://api.github.com/users/jbosstools/repos","events_url":"https://api.github.com/users/jbosstools/events{/privacy}","received_events_url":"https://api.github.com/users/jbosstools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jbosstools/jbosstools-openshift","description":"JBoss Tools :: OpenShift { openshift }","fork":false,"url":"https://api.github.com/repos/jbosstools/jbosstools-openshift","forks_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/forks","keys_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/teams","hooks_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/hooks","issue_events_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/events{/number}","events_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/events","assignees_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/assignees{/user}","branches_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/branches{/branch}","tags_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/tags","blobs_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/{sha}","languages_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/languages","stargazers_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/stargazers","contributors_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/contributors","subscribers_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/subscribers","subscription_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/subscription","commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/contents/{+path}","compare_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/merges","archive_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/downloads","issues_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues{/number}","pulls_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls{/number}","milestones_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/milestones{/number}","notifications_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/labels{/name}","releases_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/releases{/id}","deployments_url":"https://api.github.com/repos/jbosstools/jbosstools-openshift/deployments","created_at":"2012-10-20T11:23:01Z","updated_at":"2016-01-11T16:23:14Z","pushed_at":"2016-02-17T21:46:14Z","git_url":"git://github.com/jbosstools/jbosstools-openshift.git","ssh_url":"git@github.com:jbosstools/jbosstools-openshift.git","clone_url":"https://github.com/jbosstools/jbosstools-openshift.git","svn_url":"https://github.com/jbosstools/jbosstools-openshift","homepage":"","size":16141,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":9,"forks":38,"open_issues":9,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961"},"html":{"href":"https://github.com/jbosstools/jbosstools-openshift/pull/961"},"issue":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/961"},"comments":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/issues/961/comments"},"review_comments":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961/comments"},"review_comment":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/pulls/961/commits"},"statuses":{"href":"https://api.github.com/repos/jbosstools/jbosstools-openshift/statuses/28dc78e521ed56761958eef203aa169141c2555d"}}}}