andreas-schroeder / kafka-health-check

Health Check for Kafka Brokers.
MIT License
243 stars 84 forks source link

Fix bug in delAll() #32

Open andpol opened 5 years ago

andpol commented 5 years ago

Before this change, a SIGTERM resulted in the following:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/andreas-schroeder/kafka-health-check/check.delAt(0xc000018630, 0x6, 0x9, 0x6, 0xc000018630, 0x6, 0x9)
    /go/src/github.com/andreas-schroeder/kafka-health-check/check/int32_slice.go:27 +0x1f3
github.com/andreas-schroeder/kafka-health-check/check.delAll(0xc000018630, 0x8, 0x9, 0xc000000007, 0x1, 0xc0001aaa10, 0x6)
    /go/src/github.com/andreas-schroeder/kafka-health-check/check/int32_slice.go:35 +0x187
github.com/andreas-schroeder/kafka-health-check/check.(*HealthCheck).deleteTopic(0xc0000f0000, 0x798420, 0xc00000e040, 0xc0001aaa10, 0x6, 0x748196, 0x18, 0x0, 0x0, 0x0)
    /go/src/github.com/andreas-schroeder/kafka-health-check/check/setup.go:315 +0x31e
github.com/andreas-schroeder/kafka-health-check/check.(*HealthCheck).closeConnection(0xc0000f0000, 0x1)
    /go/src/github.com/andreas-schroeder/kafka-health-check/check/setup.go:294 +0x253
github.com/andreas-schroeder/kafka-health-check/check.(*HealthCheck).CheckHealth(0xc0000f0000, 0xc000128000, 0xc000128060, 0xc00001e180)
    /go/src/github.com/andreas-schroeder/kafka-health-check/check/health_check.go:107 +0x7f0
main.main()
    /go/src/github.com/andreas-schroeder/kafka-health-check/main.go:20 +0x150

This change fixes the bug on line 28 of check/int32_slice.go and adds tests.