{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/go-oidc/pulls/comments/47131802","id":47131802,"diff_hunk":"@@ -0,0 +1,61 @@\n+// This file contains tests which depend on the race detector being enabled.\n+// +build race\n+\n+package oidc\n+\n+import (\n+\t\"encoding/json\"\n+\t\"net/http\"\n+\t\"net/http/httptest\"\n+\t\"testing\"\n+\t\"time\"\n+)\n+\n+type testProvider struct {\n+\tbaseURL string\n+}\n+\n+func (p *testProvider) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n+\tif r.URL.Path != discoveryConfigPath {\n+\t\thttp.NotFound(w, r)\n+\t\treturn\n+\t}\n+\n+\tcfg := ProviderConfig{\n+\t\tIssuer: p.baseURL,\n+\t}\n+\tjson.NewEncoder(w).Encode(&cfg)\n+}\n+\n+// If this test fails by triggering the race detector, not by calling t.Error or t.Fatal.\n+func TestProviderSyncRace(t *testing.T) {\n+\tprov := &testProvider{}\n+\n+\ts := httptest.NewServer(prov)\n+\tdefer s.Close()\n+\tprov.baseURL = s.URL\n+\n+\tcliCfg := ClientConfig{\n+\t\tHTTPClient:     http.DefaultClient,\n+\t\tProviderConfig: ProviderConfig{Issuer: s.URL},\n+\t}\n+\tcli, err := NewClient(cliCfg)\n+\tif err != nil {\n+\t\tt.Error(err)\n+\t\treturn\n+\t}\n+\n+\t// SyncProviderConfig beings a goroutine which writes to the client's provider config.\n+\tc := cli.SyncProviderConfig(s.URL)\n+\tdefer func() {\n+\t\t// stop the background process\n+\t\tc <- struct{}{}\n+\t}()\n+\n+\t// Iterate serveral times to increase the likelyhood of triggering the race detector.\n+\tfor i := 0; i < 100; i++ {\n+\t\ttime.Sleep(5 * time.Millisecond)","path":"oidc/client_race_test.go","position":57,"original_position":57,"commit_id":"58dee99000f04044170dad7bcd2640dee6763344","original_commit_id":"58dee99000f04044170dad7bcd2640dee6763344","user":{"login":"yifan-gu","id":3278588,"avatar_url":"https://avatars.githubusercontent.com/u/3278588?v=3","gravatar_id":"","url":"https://api.github.com/users/yifan-gu","html_url":"https://github.com/yifan-gu","followers_url":"https://api.github.com/users/yifan-gu/followers","following_url":"https://api.github.com/users/yifan-gu/following{/other_user}","gists_url":"https://api.github.com/users/yifan-gu/gists{/gist_id}","starred_url":"https://api.github.com/users/yifan-gu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yifan-gu/subscriptions","organizations_url":"https://api.github.com/users/yifan-gu/orgs","repos_url":"https://api.github.com/users/yifan-gu/repos","events_url":"https://api.github.com/users/yifan-gu/events{/privacy}","received_events_url":"https://api.github.com/users/yifan-gu/received_events","type":"User","site_admin":false},"body":"The next sync will happen in `MinimumProviderConfigSyncInterval` which is 1 min. maybe we make that tunable for test ?","created_at":"2015-12-09T18:38:10Z","updated_at":"2015-12-09T18:38:10Z","html_url":"https://github.com/coreos/go-oidc/pull/27#discussion_r47131802","pull_request_url":"https://api.github.com/repos/coreos/go-oidc/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/comments/47131802"},"html":{"href":"https://github.com/coreos/go-oidc/pull/27#discussion_r47131802"},"pull_request":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/go-oidc/pulls/27","id":53044852,"html_url":"https://github.com/coreos/go-oidc/pull/27","diff_url":"https://github.com/coreos/go-oidc/pull/27.diff","patch_url":"https://github.com/coreos/go-oidc/pull/27.patch","issue_url":"https://api.github.com/repos/coreos/go-oidc/issues/27","number":27,"state":"open","locked":false,"title":"oidc: guard client provider config against race conditions","user":{"login":"ericchiang","id":2342749,"avatar_url":"https://avatars.githubusercontent.com/u/2342749?v=3","gravatar_id":"","url":"https://api.github.com/users/ericchiang","html_url":"https://github.com/ericchiang","followers_url":"https://api.github.com/users/ericchiang/followers","following_url":"https://api.github.com/users/ericchiang/following{/other_user}","gists_url":"https://api.github.com/users/ericchiang/gists{/gist_id}","starred_url":"https://api.github.com/users/ericchiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericchiang/subscriptions","organizations_url":"https://api.github.com/users/ericchiang/orgs","repos_url":"https://api.github.com/users/ericchiang/repos","events_url":"https://api.github.com/users/ericchiang/events{/privacy}","received_events_url":"https://api.github.com/users/ericchiang/received_events","type":"User","site_admin":false},"body":"Add a RWMutex around a client's provider config to prevent race conditions when updating after syncing.\r\n\r\nTest added which triggered the race condition before this change.\r\n\r\ncc @yifan-gu, @bobbyrullo ","created_at":"2015-12-08T21:57:34Z","updated_at":"2015-12-09T18:38:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"459f1028bcd6bc17dfae28714b02005bc4b2db8a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/go-oidc/pulls/27/commits","review_comments_url":"https://api.github.com/repos/coreos/go-oidc/pulls/27/comments","review_comment_url":"https://api.github.com/repos/coreos/go-oidc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/go-oidc/issues/27/comments","statuses_url":"https://api.github.com/repos/coreos/go-oidc/statuses/58dee99000f04044170dad7bcd2640dee6763344","head":{"label":"ericchiang:provider_cfg_race","ref":"provider_cfg_race","sha":"58dee99000f04044170dad7bcd2640dee6763344","user":{"login":"ericchiang","id":2342749,"avatar_url":"https://avatars.githubusercontent.com/u/2342749?v=3","gravatar_id":"","url":"https://api.github.com/users/ericchiang","html_url":"https://github.com/ericchiang","followers_url":"https://api.github.com/users/ericchiang/followers","following_url":"https://api.github.com/users/ericchiang/following{/other_user}","gists_url":"https://api.github.com/users/ericchiang/gists{/gist_id}","starred_url":"https://api.github.com/users/ericchiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericchiang/subscriptions","organizations_url":"https://api.github.com/users/ericchiang/orgs","repos_url":"https://api.github.com/users/ericchiang/repos","events_url":"https://api.github.com/users/ericchiang/events{/privacy}","received_events_url":"https://api.github.com/users/ericchiang/received_events","type":"User","site_admin":false},"repo":{"id":47295536,"name":"go-oidc","full_name":"ericchiang/go-oidc","owner":{"login":"ericchiang","id":2342749,"avatar_url":"https://avatars.githubusercontent.com/u/2342749?v=3","gravatar_id":"","url":"https://api.github.com/users/ericchiang","html_url":"https://github.com/ericchiang","followers_url":"https://api.github.com/users/ericchiang/followers","following_url":"https://api.github.com/users/ericchiang/following{/other_user}","gists_url":"https://api.github.com/users/ericchiang/gists{/gist_id}","starred_url":"https://api.github.com/users/ericchiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericchiang/subscriptions","organizations_url":"https://api.github.com/users/ericchiang/orgs","repos_url":"https://api.github.com/users/ericchiang/repos","events_url":"https://api.github.com/users/ericchiang/events{/privacy}","received_events_url":"https://api.github.com/users/ericchiang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericchiang/go-oidc","description":"Go libraries for implementing OIDC clients and servers","fork":true,"url":"https://api.github.com/repos/ericchiang/go-oidc","forks_url":"https://api.github.com/repos/ericchiang/go-oidc/forks","keys_url":"https://api.github.com/repos/ericchiang/go-oidc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericchiang/go-oidc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericchiang/go-oidc/teams","hooks_url":"https://api.github.com/repos/ericchiang/go-oidc/hooks","issue_events_url":"https://api.github.com/repos/ericchiang/go-oidc/issues/events{/number}","events_url":"https://api.github.com/repos/ericchiang/go-oidc/events","assignees_url":"https://api.github.com/repos/ericchiang/go-oidc/assignees{/user}","branches_url":"https://api.github.com/repos/ericchiang/go-oidc/branches{/branch}","tags_url":"https://api.github.com/repos/ericchiang/go-oidc/tags","blobs_url":"https://api.github.com/repos/ericchiang/go-oidc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericchiang/go-oidc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericchiang/go-oidc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericchiang/go-oidc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericchiang/go-oidc/statuses/{sha}","languages_url":"https://api.github.com/repos/ericchiang/go-oidc/languages","stargazers_url":"https://api.github.com/repos/ericchiang/go-oidc/stargazers","contributors_url":"https://api.github.com/repos/ericchiang/go-oidc/contributors","subscribers_url":"https://api.github.com/repos/ericchiang/go-oidc/subscribers","subscription_url":"https://api.github.com/repos/ericchiang/go-oidc/subscription","commits_url":"https://api.github.com/repos/ericchiang/go-oidc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericchiang/go-oidc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericchiang/go-oidc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericchiang/go-oidc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ericchiang/go-oidc/contents/{+path}","compare_url":"https://api.github.com/repos/ericchiang/go-oidc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericchiang/go-oidc/merges","archive_url":"https://api.github.com/repos/ericchiang/go-oidc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericchiang/go-oidc/downloads","issues_url":"https://api.github.com/repos/ericchiang/go-oidc/issues{/number}","pulls_url":"https://api.github.com/repos/ericchiang/go-oidc/pulls{/number}","milestones_url":"https://api.github.com/repos/ericchiang/go-oidc/milestones{/number}","notifications_url":"https://api.github.com/repos/ericchiang/go-oidc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericchiang/go-oidc/labels{/name}","releases_url":"https://api.github.com/repos/ericchiang/go-oidc/releases{/id}","created_at":"2015-12-02T23:45:52Z","updated_at":"2015-12-02T23:45:53Z","pushed_at":"2015-12-09T17:43:03Z","git_url":"git://github.com/ericchiang/go-oidc.git","ssh_url":"git@github.com:ericchiang/go-oidc.git","clone_url":"https://github.com/ericchiang/go-oidc.git","svn_url":"https://github.com/ericchiang/go-oidc","homepage":"","size":82,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"coreos:master","ref":"master","sha":"faf70c34f9c411f234eb96d23c518c087cd96d79","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":38275789,"name":"go-oidc","full_name":"coreos/go-oidc","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/go-oidc","description":"Go libraries for implementing OIDC clients and servers","fork":false,"url":"https://api.github.com/repos/coreos/go-oidc","forks_url":"https://api.github.com/repos/coreos/go-oidc/forks","keys_url":"https://api.github.com/repos/coreos/go-oidc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/go-oidc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/go-oidc/teams","hooks_url":"https://api.github.com/repos/coreos/go-oidc/hooks","issue_events_url":"https://api.github.com/repos/coreos/go-oidc/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/go-oidc/events","assignees_url":"https://api.github.com/repos/coreos/go-oidc/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/go-oidc/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/go-oidc/tags","blobs_url":"https://api.github.com/repos/coreos/go-oidc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/go-oidc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/go-oidc/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/go-oidc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/go-oidc/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/go-oidc/languages","stargazers_url":"https://api.github.com/repos/coreos/go-oidc/stargazers","contributors_url":"https://api.github.com/repos/coreos/go-oidc/contributors","subscribers_url":"https://api.github.com/repos/coreos/go-oidc/subscribers","subscription_url":"https://api.github.com/repos/coreos/go-oidc/subscription","commits_url":"https://api.github.com/repos/coreos/go-oidc/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/go-oidc/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/go-oidc/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/go-oidc/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/go-oidc/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/go-oidc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/go-oidc/merges","archive_url":"https://api.github.com/repos/coreos/go-oidc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/go-oidc/downloads","issues_url":"https://api.github.com/repos/coreos/go-oidc/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/go-oidc/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/go-oidc/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/go-oidc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/go-oidc/labels{/name}","releases_url":"https://api.github.com/repos/coreos/go-oidc/releases{/id}","created_at":"2015-06-29T23:06:33Z","updated_at":"2015-12-06T11:07:54Z","pushed_at":"2015-12-09T17:43:16Z","git_url":"git://github.com/coreos/go-oidc.git","ssh_url":"git@github.com:coreos/go-oidc.git","clone_url":"https://github.com/coreos/go-oidc.git","svn_url":"https://github.com/coreos/go-oidc","homepage":"","size":79,"stargazers_count":59,"watchers_count":59,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":10,"forks":8,"open_issues":10,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/27"},"html":{"href":"https://github.com/coreos/go-oidc/pull/27"},"issue":{"href":"https://api.github.com/repos/coreos/go-oidc/issues/27"},"comments":{"href":"https://api.github.com/repos/coreos/go-oidc/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/go-oidc/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/go-oidc/statuses/58dee99000f04044170dad7bcd2640dee6763344"}}}}