Skip to content

Commit

Permalink
fix fatal error: concurrent map iteration and map write
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzlei committed Mar 12, 2024
1 parent a0604c5 commit 3be6b09
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions instrumentation/awsv2/awsv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func deserializeMiddleware(stack *middleware.Stack) error {
return out, metadata, err
}

// Lock subseg before updating
subseg.Lock()

subseg.GetHTTP().GetResponse().ContentLength = int(resp.ContentLength)
requestID, ok := v2Middleware.GetRequestIDMetadata(metadata)

Expand All @@ -77,6 +80,8 @@ func deserializeMiddleware(stack *middleware.Stack) error {
subseg.GetAWS()[xray.ExtendedRequestIDKey] = extendedRequestID
}

subseg.Unlock()

xray.HttpCaptureResponse(subseg, resp.StatusCode)
return out, metadata, err
}),
Expand Down

0 comments on commit 3be6b09

Please sign in to comment.