Skip to content

Commit 6867ee3

Browse files
committed
Address review feedback to eliminate race condition
1 parent 9a0e1df commit 6867ee3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

github/github.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ type service struct {
192192
func (c *Client) Client() *http.Client {
193193
c.clientMu.Lock()
194194
defer c.clientMu.Unlock()
195-
return c.client
195+
clientCopy := *c.client
196+
return &clientCopy
196197
}
197198

198199
// ListOptions specifies the optional parameters to various List methods that

github/github_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ func TestNewClient(t *testing.T) {
235235
func TestClient(t *testing.T) {
236236
c := NewClient(nil)
237237
c2 := c.Client()
238-
if c.client != c2 {
239-
t.Error("Client returned different http.Client, but should be the same.")
238+
if c.client == c2 {
239+
t.Error("Client returned same http.Client, but should be different")
240240
}
241241
}
242242

0 commit comments

Comments
 (0)