Skip to content

Commit

Permalink
Add nil checks to agent_handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kessler committed Jan 7, 2025
1 parent 35bb3fb commit 8e53ca7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions agent_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ func (a *Agent) OnCandidate(f func(Candidate)) error {
}

func (a *Agent) onSelectedCandidatePairChange(p *CandidatePair) {
if h, ok := a.onSelectedCandidatePairChangeHdlr.Load().(func(Candidate, Candidate)); ok {
if h, ok := a.onSelectedCandidatePairChangeHdlr.Load().(func(Candidate, Candidate)); ok && h != nil {

Check warning on line 29 in agent_handlers.go

View check run for this annotation

Codecov / codecov/patch

agent_handlers.go#L29

Added line #L29 was not covered by tests
h(p.Local, p.Remote)
}
}

func (a *Agent) onCandidate(c Candidate) {
if onCandidateHdlr, ok := a.onCandidateHdlr.Load().(func(Candidate)); ok {
if onCandidateHdlr, ok := a.onCandidateHdlr.Load().(func(Candidate)); ok && onCandidateHdlr != nil {

Check warning on line 35 in agent_handlers.go

View check run for this annotation

Codecov / codecov/patch

agent_handlers.go#L35

Added line #L35 was not covered by tests
onCandidateHdlr(c)
}
}

func (a *Agent) onConnectionStateChange(s ConnectionState) {
if hdlr, ok := a.onConnectionStateChangeHdlr.Load().(func(ConnectionState)); ok {
if hdlr, ok := a.onConnectionStateChangeHdlr.Load().(func(ConnectionState)); ok && hdlr != nil {

Check warning on line 41 in agent_handlers.go

View check run for this annotation

Codecov / codecov/patch

agent_handlers.go#L41

Added line #L41 was not covered by tests
hdlr(s)
}
}
Expand Down

0 comments on commit 8e53ca7

Please sign in to comment.