{"action":"created","comment":{"url":"https://api.github.com/repos/temenostech/IRIS/pulls/comments/61224202","id":61224202,"diff_hunk":"@@ -440,31 +464,43 @@ private void collectTransitionsByIdForState(ResourceState state) {\n      *            as multiple states can share the same path\n      */\n \tpublic synchronized void unregister(ResourceState state, String method) {\n-\t\tcheckAndResolve(state);\n-\t\tallStates.remove(state);\n-\t\t// collectTransitionsById(transitionsById, state);\n-\t\t// collectTransitionsByRel(transitionsByRel, state);\n \n-        // Process interactions by path\n-\t\tfinal Set<String> pathInteractions = interactionsByPath.get(state.getPath());\n+\t\t// don't do anything if the state is not registered\n+\t\tif(!resourceStatesByName.containsKey(state.getName())) return;\n \n-        if (pathInteractions != null)\n-\t\t\tpathInteractions.remove(method);\n+\t\t// remove transitions originating in state for this method only\n+        for (Transition transition : state.getTransitions()) {\n+            if(transition.getCommand().getMethod() == method)\n+                transitionsById.remove(transition.getId());\n+        }\n+\n+        // remove transitions originating in state for this method only\n+        for (Transition transition : state.getTransitions()) {\n+            if (transition.getTarget() != null) {\n+                if(transition.getCommand().getMethod() == method)\n+                    transitionsByRel.remove(transition.getTarget().getRel());\n+            }\n+        }\n \n-        // Process interactions by state\n-\t\tfinal Set<String> stateInteractions = interactionsByState.get(state);\n+        // Process interactions by path\n+        final Set<String> pathInteractions = interactionsByPath.get(state.getPath());\n+        if (pathInteractions != null)\n+            pathInteractions.remove(method);\n \n+\t\t// Process interactions by state\n+        final Set<String> stateInteractions = interactionsByState.get(state.getName());\n         if (stateInteractions != null)\n-\t\t\tstateInteractions.remove(method);\n+            stateInteractions.remove(method);\n \n         // Process resource states by path\n-\t\tfinal Set<ResourceState> pathStates = resourceStatesByPath.get(state.getResourcePath());\n-\n-        if (pathStates != null)\n-\t\t\tpathStates.remove(state);\n+        final Set<String> pathStateNames = resourceStateNamesByPath.get(state.getResourcePath());\n+        if (pathStateNames != null)\n+            pathStateNames.remove(state);\n \n-\t\t// Process resource states by name\n-\t\tresourceStatesByName.remove(state.getName());\n+\t\t// only remove if there are no methods associated with the state\n+\t\tif(stateInteractions != null)\n+\t\t\tif(stateInteractions.size() == 0)","path":"interaction-core/src/main/java/com/temenos/interaction/core/hypermedia/ResourceStateMachine.java","position":266,"original_position":266,"commit_id":"d449b0c744ea99bfaddb20551664f14f56b68e8e","original_commit_id":"d449b0c744ea99bfaddb20551664f14f56b68e8e","user":{"login":"mtemenos","id":7769860,"avatar_url":"https://avatars.githubusercontent.com/u/7769860?v=3","gravatar_id":"","url":"https://api.github.com/users/mtemenos","html_url":"https://github.com/mtemenos","followers_url":"https://api.github.com/users/mtemenos/followers","following_url":"https://api.github.com/users/mtemenos/following{/other_user}","gists_url":"https://api.github.com/users/mtemenos/gists{/gist_id}","starred_url":"https://api.github.com/users/mtemenos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtemenos/subscriptions","organizations_url":"https://api.github.com/users/mtemenos/orgs","repos_url":"https://api.github.com/users/mtemenos/repos","events_url":"https://api.github.com/users/mtemenos/events{/privacy}","received_events_url":"https://api.github.com/users/mtemenos/received_events","type":"User","site_admin":false},"body":"stateInteractions.isEmpty() is the recommended pattern","created_at":"2016-04-27T08:54:58Z","updated_at":"2016-04-27T08:54:58Z","html_url":"https://github.com/temenostech/IRIS/pull/375#discussion_r61224202","pull_request_url":"https://api.github.com/repos/temenostech/IRIS/pulls/375","_links":{"self":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/comments/61224202"},"html":{"href":"https://github.com/temenostech/IRIS/pull/375#discussion_r61224202"},"pull_request":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/375"}}},"pull_request":{"url":"https://api.github.com/repos/temenostech/IRIS/pulls/375","id":67704900,"html_url":"https://github.com/temenostech/IRIS/pull/375","diff_url":"https://github.com/temenostech/IRIS/pull/375.diff","patch_url":"https://github.com/temenostech/IRIS/pull/375.patch","issue_url":"https://api.github.com/repos/temenostech/IRIS/issues/375","number":375,"state":"open","locked":false,"title":"RTC-1594488: Fix for dynamic loading of resources.","user":{"login":"schwadorf","id":4589589,"avatar_url":"https://avatars.githubusercontent.com/u/4589589?v=3","gravatar_id":"","url":"https://api.github.com/users/schwadorf","html_url":"https://github.com/schwadorf","followers_url":"https://api.github.com/users/schwadorf/followers","following_url":"https://api.github.com/users/schwadorf/following{/other_user}","gists_url":"https://api.github.com/users/schwadorf/gists{/gist_id}","starred_url":"https://api.github.com/users/schwadorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwadorf/subscriptions","organizations_url":"https://api.github.com/users/schwadorf/orgs","repos_url":"https://api.github.com/users/schwadorf/repos","events_url":"https://api.github.com/users/schwadorf/events{/privacy}","received_events_url":"https://api.github.com/users/schwadorf/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-25T11:35:56Z","updated_at":"2016-04-27T08:54:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e8d5ec6db599c4d5f30acd54b2d6e9f60f3d0a0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/temenostech/IRIS/pulls/375/commits","review_comments_url":"https://api.github.com/repos/temenostech/IRIS/pulls/375/comments","review_comment_url":"https://api.github.com/repos/temenostech/IRIS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/temenostech/IRIS/issues/375/comments","statuses_url":"https://api.github.com/repos/temenostech/IRIS/statuses/d449b0c744ea99bfaddb20551664f14f56b68e8e","head":{"label":"schwadorf:RTC-1594488","ref":"RTC-1594488","sha":"d449b0c744ea99bfaddb20551664f14f56b68e8e","user":{"login":"schwadorf","id":4589589,"avatar_url":"https://avatars.githubusercontent.com/u/4589589?v=3","gravatar_id":"","url":"https://api.github.com/users/schwadorf","html_url":"https://github.com/schwadorf","followers_url":"https://api.github.com/users/schwadorf/followers","following_url":"https://api.github.com/users/schwadorf/following{/other_user}","gists_url":"https://api.github.com/users/schwadorf/gists{/gist_id}","starred_url":"https://api.github.com/users/schwadorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwadorf/subscriptions","organizations_url":"https://api.github.com/users/schwadorf/orgs","repos_url":"https://api.github.com/users/schwadorf/repos","events_url":"https://api.github.com/users/schwadorf/events{/privacy}","received_events_url":"https://api.github.com/users/schwadorf/received_events","type":"User","site_admin":false},"repo":{"id":49208432,"name":"IRIS","full_name":"schwadorf/IRIS","owner":{"login":"schwadorf","id":4589589,"avatar_url":"https://avatars.githubusercontent.com/u/4589589?v=3","gravatar_id":"","url":"https://api.github.com/users/schwadorf","html_url":"https://github.com/schwadorf","followers_url":"https://api.github.com/users/schwadorf/followers","following_url":"https://api.github.com/users/schwadorf/following{/other_user}","gists_url":"https://api.github.com/users/schwadorf/gists{/gist_id}","starred_url":"https://api.github.com/users/schwadorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwadorf/subscriptions","organizations_url":"https://api.github.com/users/schwadorf/orgs","repos_url":"https://api.github.com/users/schwadorf/repos","events_url":"https://api.github.com/users/schwadorf/events{/privacy}","received_events_url":"https://api.github.com/users/schwadorf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/schwadorf/IRIS","description":"Temenos Interaction, Reporting & Information Services","fork":true,"url":"https://api.github.com/repos/schwadorf/IRIS","forks_url":"https://api.github.com/repos/schwadorf/IRIS/forks","keys_url":"https://api.github.com/repos/schwadorf/IRIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schwadorf/IRIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schwadorf/IRIS/teams","hooks_url":"https://api.github.com/repos/schwadorf/IRIS/hooks","issue_events_url":"https://api.github.com/repos/schwadorf/IRIS/issues/events{/number}","events_url":"https://api.github.com/repos/schwadorf/IRIS/events","assignees_url":"https://api.github.com/repos/schwadorf/IRIS/assignees{/user}","branches_url":"https://api.github.com/repos/schwadorf/IRIS/branches{/branch}","tags_url":"https://api.github.com/repos/schwadorf/IRIS/tags","blobs_url":"https://api.github.com/repos/schwadorf/IRIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schwadorf/IRIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schwadorf/IRIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/schwadorf/IRIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schwadorf/IRIS/statuses/{sha}","languages_url":"https://api.github.com/repos/schwadorf/IRIS/languages","stargazers_url":"https://api.github.com/repos/schwadorf/IRIS/stargazers","contributors_url":"https://api.github.com/repos/schwadorf/IRIS/contributors","subscribers_url":"https://api.github.com/repos/schwadorf/IRIS/subscribers","subscription_url":"https://api.github.com/repos/schwadorf/IRIS/subscription","commits_url":"https://api.github.com/repos/schwadorf/IRIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/schwadorf/IRIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/schwadorf/IRIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/schwadorf/IRIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/schwadorf/IRIS/contents/{+path}","compare_url":"https://api.github.com/repos/schwadorf/IRIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schwadorf/IRIS/merges","archive_url":"https://api.github.com/repos/schwadorf/IRIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schwadorf/IRIS/downloads","issues_url":"https://api.github.com/repos/schwadorf/IRIS/issues{/number}","pulls_url":"https://api.github.com/repos/schwadorf/IRIS/pulls{/number}","milestones_url":"https://api.github.com/repos/schwadorf/IRIS/milestones{/number}","notifications_url":"https://api.github.com/repos/schwadorf/IRIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schwadorf/IRIS/labels{/name}","releases_url":"https://api.github.com/repos/schwadorf/IRIS/releases{/id}","deployments_url":"https://api.github.com/repos/schwadorf/IRIS/deployments","created_at":"2016-01-07T14:12:55Z","updated_at":"2016-04-07T15:09:25Z","pushed_at":"2016-04-27T08:49:44Z","git_url":"git://github.com/schwadorf/IRIS.git","ssh_url":"git@github.com:schwadorf/IRIS.git","clone_url":"https://github.com/schwadorf/IRIS.git","svn_url":"https://github.com/schwadorf/IRIS","homepage":"","size":15367,"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":"temenostech:master","ref":"master","sha":"07912f94354255c8c6f715f1b52eac25cfc4001d","user":{"login":"temenostech","id":5080721,"avatar_url":"https://avatars.githubusercontent.com/u/5080721?v=3","gravatar_id":"","url":"https://api.github.com/users/temenostech","html_url":"https://github.com/temenostech","followers_url":"https://api.github.com/users/temenostech/followers","following_url":"https://api.github.com/users/temenostech/following{/other_user}","gists_url":"https://api.github.com/users/temenostech/gists{/gist_id}","starred_url":"https://api.github.com/users/temenostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/temenostech/subscriptions","organizations_url":"https://api.github.com/users/temenostech/orgs","repos_url":"https://api.github.com/users/temenostech/repos","events_url":"https://api.github.com/users/temenostech/events{/privacy}","received_events_url":"https://api.github.com/users/temenostech/received_events","type":"Organization","site_admin":false},"repo":{"id":2802488,"name":"IRIS","full_name":"temenostech/IRIS","owner":{"login":"temenostech","id":5080721,"avatar_url":"https://avatars.githubusercontent.com/u/5080721?v=3","gravatar_id":"","url":"https://api.github.com/users/temenostech","html_url":"https://github.com/temenostech","followers_url":"https://api.github.com/users/temenostech/followers","following_url":"https://api.github.com/users/temenostech/following{/other_user}","gists_url":"https://api.github.com/users/temenostech/gists{/gist_id}","starred_url":"https://api.github.com/users/temenostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/temenostech/subscriptions","organizations_url":"https://api.github.com/users/temenostech/orgs","repos_url":"https://api.github.com/users/temenostech/repos","events_url":"https://api.github.com/users/temenostech/events{/privacy}","received_events_url":"https://api.github.com/users/temenostech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/temenostech/IRIS","description":"Temenos Interaction, Reporting & Information Services","fork":false,"url":"https://api.github.com/repos/temenostech/IRIS","forks_url":"https://api.github.com/repos/temenostech/IRIS/forks","keys_url":"https://api.github.com/repos/temenostech/IRIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/temenostech/IRIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/temenostech/IRIS/teams","hooks_url":"https://api.github.com/repos/temenostech/IRIS/hooks","issue_events_url":"https://api.github.com/repos/temenostech/IRIS/issues/events{/number}","events_url":"https://api.github.com/repos/temenostech/IRIS/events","assignees_url":"https://api.github.com/repos/temenostech/IRIS/assignees{/user}","branches_url":"https://api.github.com/repos/temenostech/IRIS/branches{/branch}","tags_url":"https://api.github.com/repos/temenostech/IRIS/tags","blobs_url":"https://api.github.com/repos/temenostech/IRIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/temenostech/IRIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/temenostech/IRIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/temenostech/IRIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/temenostech/IRIS/statuses/{sha}","languages_url":"https://api.github.com/repos/temenostech/IRIS/languages","stargazers_url":"https://api.github.com/repos/temenostech/IRIS/stargazers","contributors_url":"https://api.github.com/repos/temenostech/IRIS/contributors","subscribers_url":"https://api.github.com/repos/temenostech/IRIS/subscribers","subscription_url":"https://api.github.com/repos/temenostech/IRIS/subscription","commits_url":"https://api.github.com/repos/temenostech/IRIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/temenostech/IRIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/temenostech/IRIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/temenostech/IRIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/temenostech/IRIS/contents/{+path}","compare_url":"https://api.github.com/repos/temenostech/IRIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/temenostech/IRIS/merges","archive_url":"https://api.github.com/repos/temenostech/IRIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/temenostech/IRIS/downloads","issues_url":"https://api.github.com/repos/temenostech/IRIS/issues{/number}","pulls_url":"https://api.github.com/repos/temenostech/IRIS/pulls{/number}","milestones_url":"https://api.github.com/repos/temenostech/IRIS/milestones{/number}","notifications_url":"https://api.github.com/repos/temenostech/IRIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/temenostech/IRIS/labels{/name}","releases_url":"https://api.github.com/repos/temenostech/IRIS/releases{/id}","deployments_url":"https://api.github.com/repos/temenostech/IRIS/deployments","created_at":"2011-11-18T12:45:12Z","updated_at":"2016-03-26T17:00:06Z","pushed_at":"2016-04-27T08:49:44Z","git_url":"git://github.com/temenostech/IRIS.git","ssh_url":"git@github.com:temenostech/IRIS.git","clone_url":"https://github.com/temenostech/IRIS.git","svn_url":"https://github.com/temenostech/IRIS","homepage":"","size":16413,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":61,"mirror_url":null,"open_issues_count":49,"forks":61,"open_issues":49,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/375"},"html":{"href":"https://github.com/temenostech/IRIS/pull/375"},"issue":{"href":"https://api.github.com/repos/temenostech/IRIS/issues/375"},"comments":{"href":"https://api.github.com/repos/temenostech/IRIS/issues/375/comments"},"review_comments":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/375/comments"},"review_comment":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/temenostech/IRIS/pulls/375/commits"},"statuses":{"href":"https://api.github.com/repos/temenostech/IRIS/statuses/d449b0c744ea99bfaddb20551664f14f56b68e8e"}}}}