Skip to content

Commit

Permalink
fix(contrib/net/http): avoid race condition on request value
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Sep 2, 2024
1 parent 8c646bb commit bb94c3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/net/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ func TestServeMuxGo122Patterns(t *testing.T) {
func TestWrapHandlerWithResourceNameNoRace(_ *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
r := httptest.NewRequest("GET", "/", nil)
resourceNamer := func(_ *http.Request) string {
return "custom-resource-name"
}
Expand All @@ -358,6 +357,7 @@ func TestWrapHandlerWithResourceNameNoRace(_ *testing.T) {
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
r := httptest.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
defer wg.Done()
mux.ServeHTTP(w, r)
Expand All @@ -369,14 +369,14 @@ func TestWrapHandlerWithResourceNameNoRace(_ *testing.T) {
func TestServeMuxNoRace(_ *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
r := httptest.NewRequest("GET", "/", nil)
mux := NewServeMux()
mux.Handle("/", http.NotFoundHandler())

wg := sync.WaitGroup{}
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
r := httptest.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
defer wg.Done()
mux.ServeHTTP(w, r)
Expand Down

0 comments on commit bb94c3e

Please sign in to comment.