Skip to content

Commit

Permalink
fix: combinedHealthCheckSource skips nil members to avoid panics (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoylan authored Aug 17, 2021
1 parent 4a7b953 commit bbed8ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-45.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: CombinedHealthCheckSource skips nil members to avoid panics
links:
- https://github.com/palantir/witchcraft-go-health/pull/45
3 changes: 3 additions & 0 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (c *combinedHealthCheckSource) HealthStatus(ctx context.Context) health.Hea
Checks: map[health.CheckType]health.HealthCheckResult{},
}
for _, healthCheckSource := range c.healthCheckSources {
if healthCheckSource == nil {
continue
}
for k, v := range healthCheckSource.HealthStatus(ctx).Checks {
result.Checks[k] = v
}
Expand Down
2 changes: 1 addition & 1 deletion status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestCombinedHealthCheckSource(t *testing.T) {
},
},
}
combined := NewCombinedHealthCheckSource(sourceA, sourceB)
combined := NewCombinedHealthCheckSource(sourceA, sourceB, nil)
actual := combined.HealthStatus(context.Background())
assert.Equal(t, health.HealthStatus{
Checks: map[health.CheckType]health.HealthCheckResult{
Expand Down

0 comments on commit bbed8ec

Please sign in to comment.