{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Caching/pulls/comments/46310491","id":46310491,"diff_hunk":"@@ -125,22 +130,29 @@ internal void AttachTokens()\n \n         private static void ExpirationTokensExpired(object obj)\n         {\n-            var entry = (CacheEntry)obj;\n-            entry.SetExpired(EvictionReason.TokenExpired);\n-            entry._notifyCacheOfExpiration(entry);\n+            // start a new thread to avoid issues with callbacks called from RegisterChangeCallback\n+            Task.Factory.StartNew(state =>\n+            {\n+                var entry = (CacheEntry)state;\n+                entry.SetExpired(EvictionReason.TokenExpired);\n+                entry._notifyCacheOfExpiration(entry);\n+            }, obj, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);\n         }\n \n         // TODO: Thread safety","path":"src/Microsoft.Extensions.Caching.Memory/CacheEntry.cs","position":53,"original_position":53,"commit_id":"b1e863977692099e69fceb17fa42fe5495d54b33","original_commit_id":"b1e863977692099e69fceb17fa42fe5495d54b33","user":{"login":"Tratcher","id":1821173,"avatar_url":"https://avatars.githubusercontent.com/u/1821173?v=3","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"body":"You can remove this TODO","created_at":"2015-12-01T17:38:01Z","updated_at":"2015-12-01T17:38:01Z","html_url":"https://github.com/aspnet/Caching/pull/126#discussion_r46310491","pull_request_url":"https://api.github.com/repos/aspnet/Caching/pulls/126","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/comments/46310491"},"html":{"href":"https://github.com/aspnet/Caching/pull/126#discussion_r46310491"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Caching/pulls/126","id":51694187,"html_url":"https://github.com/aspnet/Caching/pull/126","diff_url":"https://github.com/aspnet/Caching/pull/126.diff","patch_url":"https://github.com/aspnet/Caching/pull/126.patch","issue_url":"https://api.github.com/repos/aspnet/Caching/issues/126","number":126,"state":"open","locked":false,"title":"Fix race between Attach and Detach Tokens","user":{"login":"BrennanConroy","id":7574801,"avatar_url":"https://avatars.githubusercontent.com/u/7574801?v=3","gravatar_id":"","url":"https://api.github.com/users/BrennanConroy","html_url":"https://github.com/BrennanConroy","followers_url":"https://api.github.com/users/BrennanConroy/followers","following_url":"https://api.github.com/users/BrennanConroy/following{/other_user}","gists_url":"https://api.github.com/users/BrennanConroy/gists{/gist_id}","starred_url":"https://api.github.com/users/BrennanConroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrennanConroy/subscriptions","organizations_url":"https://api.github.com/users/BrennanConroy/orgs","repos_url":"https://api.github.com/users/BrennanConroy/repos","events_url":"https://api.github.com/users/BrennanConroy/events{/privacy}","received_events_url":"https://api.github.com/users/BrennanConroy/received_events","type":"User","site_admin":false},"body":"Fixes part of #17 at least\r\n@Tratcher ","created_at":"2015-11-24T17:55:17Z","updated_at":"2015-12-01T17:38:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a10713ab02bf42ac30d451337b5d59768b30ee7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Caching/pulls/126/commits","review_comments_url":"https://api.github.com/repos/aspnet/Caching/pulls/126/comments","review_comment_url":"https://api.github.com/repos/aspnet/Caching/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Caching/issues/126/comments","statuses_url":"https://api.github.com/repos/aspnet/Caching/statuses/b1e863977692099e69fceb17fa42fe5495d54b33","head":{"label":"aspnet:brecon/safe_t","ref":"brecon/safe_t","sha":"b1e863977692099e69fceb17fa42fe5495d54b33","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":22390590,"name":"Caching","full_name":"aspnet/Caching","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Caching","description":"Libraries for caching, including in-memory caching, distributed caching, and ASP.NET session caching.","fork":false,"url":"https://api.github.com/repos/aspnet/Caching","forks_url":"https://api.github.com/repos/aspnet/Caching/forks","keys_url":"https://api.github.com/repos/aspnet/Caching/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Caching/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Caching/teams","hooks_url":"https://api.github.com/repos/aspnet/Caching/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Caching/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Caching/events","assignees_url":"https://api.github.com/repos/aspnet/Caching/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Caching/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Caching/tags","blobs_url":"https://api.github.com/repos/aspnet/Caching/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Caching/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Caching/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Caching/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Caching/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Caching/languages","stargazers_url":"https://api.github.com/repos/aspnet/Caching/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Caching/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Caching/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Caching/subscription","commits_url":"https://api.github.com/repos/aspnet/Caching/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Caching/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Caching/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Caching/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Caching/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Caching/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Caching/merges","archive_url":"https://api.github.com/repos/aspnet/Caching/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Caching/downloads","issues_url":"https://api.github.com/repos/aspnet/Caching/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Caching/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Caching/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Caching/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Caching/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Caching/releases{/id}","created_at":"2014-07-29T18:25:32Z","updated_at":"2015-11-30T07:27:27Z","pushed_at":"2015-11-30T18:49:59Z","git_url":"git://github.com/aspnet/Caching.git","ssh_url":"git@github.com:aspnet/Caching.git","clone_url":"https://github.com/aspnet/Caching.git","svn_url":"https://github.com/aspnet/Caching","homepage":"","size":943,"stargazers_count":112,"watchers_count":112,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":16,"forks":62,"open_issues":16,"watchers":112,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"834385ee7495571550b2f0eb2ffd2c7fe6725dbe","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":22390590,"name":"Caching","full_name":"aspnet/Caching","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Caching","description":"Libraries for caching, including in-memory caching, distributed caching, and ASP.NET session caching.","fork":false,"url":"https://api.github.com/repos/aspnet/Caching","forks_url":"https://api.github.com/repos/aspnet/Caching/forks","keys_url":"https://api.github.com/repos/aspnet/Caching/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Caching/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Caching/teams","hooks_url":"https://api.github.com/repos/aspnet/Caching/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Caching/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Caching/events","assignees_url":"https://api.github.com/repos/aspnet/Caching/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Caching/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Caching/tags","blobs_url":"https://api.github.com/repos/aspnet/Caching/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Caching/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Caching/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Caching/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Caching/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Caching/languages","stargazers_url":"https://api.github.com/repos/aspnet/Caching/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Caching/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Caching/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Caching/subscription","commits_url":"https://api.github.com/repos/aspnet/Caching/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Caching/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Caching/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Caching/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Caching/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Caching/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Caching/merges","archive_url":"https://api.github.com/repos/aspnet/Caching/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Caching/downloads","issues_url":"https://api.github.com/repos/aspnet/Caching/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Caching/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Caching/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Caching/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Caching/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Caching/releases{/id}","created_at":"2014-07-29T18:25:32Z","updated_at":"2015-11-30T07:27:27Z","pushed_at":"2015-11-30T18:49:59Z","git_url":"git://github.com/aspnet/Caching.git","ssh_url":"git@github.com:aspnet/Caching.git","clone_url":"https://github.com/aspnet/Caching.git","svn_url":"https://github.com/aspnet/Caching","homepage":"","size":943,"stargazers_count":112,"watchers_count":112,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":16,"forks":62,"open_issues":16,"watchers":112,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/126"},"html":{"href":"https://github.com/aspnet/Caching/pull/126"},"issue":{"href":"https://api.github.com/repos/aspnet/Caching/issues/126"},"comments":{"href":"https://api.github.com/repos/aspnet/Caching/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Caching/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Caching/statuses/b1e863977692099e69fceb17fa42fe5495d54b33"}}}}