Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Fix data race in collector registrar
Browse files Browse the repository at this point in the history
[#96196680]

Signed-off-by: John Tuley <jtuley@pivotal.io>
  • Loading branch information
Kira Combs authored and John Tuley committed Jun 10, 2015
1 parent 1e8c928 commit 37332fe
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ var _ = Describe("Collectorregistrar", func() {
}
registrar = collectorregistrar.NewCollectorRegistrar(fakeClientProvider, component, 10*time.Millisecond, nil)
doneChan = make(chan struct{})
})

JustBeforeEach(func() {
// Wait until after all BeforeEach's are done. This prevents a race condition with the
// BeforeEach below ("with errors from the client provider")
go func() {
defer close(doneChan)
registrar.Run()
Expand Down Expand Up @@ -77,11 +81,14 @@ var _ = Describe("Collectorregistrar", func() {
Context("with errors", func() {
Context("from the client provider", func() {
BeforeEach(func() {
fakeError := errors.New("fake error")
calledOnce := false
errorProvider = func() error {
returnedError := fakeError
fakeError = nil
return returnedError
if calledOnce {
return nil
}

calledOnce = true
return errors.New("fake error")
}
})

Expand Down

0 comments on commit 37332fe

Please sign in to comment.