Skip to content

Commit

Permalink
fix: use proto.Equal to compare protobuf messages (#125)
Browse files Browse the repository at this point in the history
replace reflect deepequal with proto.Equal

reflection is comparing some internal fields used during marshaling, causing race
conditions in the beats reloader code.
the race condition causes APM Server tests to fail with the race detector enabled
  • Loading branch information
kruskall authored Nov 26, 2024
1 parent 86f524d commit e5ee8f8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/client/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package client

import (
"reflect"
"sync"

gproto "google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -206,7 +205,7 @@ func (u *Unit) UpdateState(state UnitState, message string, payload map[string]i
}
if (u.statePayload == nil && statePayload != nil) ||
(u.statePayload != nil && statePayload == nil) ||
!reflect.DeepEqual(u.statePayload, statePayload) {
!gproto.Equal(u.statePayload, statePayload) {
u.statePayload = statePayload
changed = true
}
Expand Down

0 comments on commit e5ee8f8

Please sign in to comment.