From 6dd9a5247cb410cf55e569f3522dce0a871d26dc Mon Sep 17 00:00:00 2001 From: Martin Sucha Date: Fri, 26 Aug 2016 18:03:41 +0200 Subject: [PATCH] Fix handling of Notify.Interval default When there are no SMTP settings and you use e.g. a Slack notifier without this patch it results in the following panic: ``` panic: invalid argument to Int63n goroutine 988 [running]: panic(0x7c0880, 0xc420e64240) $GOROOT/src/runtime/panic.go:500 +0x1a1 math/rand.(*Rand).Int63n(0xc420076080, 0x0, 0x0) $GOROOT/src/math/rand/rand.go:82 +0x13e math/rand.Int63n(0x0, 0x0) $GOROOT/src/math/rand/rand.go:237 +0x37 main.(*NotifyCenter).startConsumerGroupEvaluator(0xc420e1f020, 0xc420314750, 0x22, 0xc420112cb0, 0x4) $GOPATH/src/github.com/linkedin/burrow/notify_center.go:166 +0x40 created by main.(*NotifyCenter).refreshConsumerGroups $GOPATH/src/github.com/linkedin/burrow/notify_center.go:149 +0x775 ``` --- config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index e1c21727..c3116235 100644 --- a/config.go +++ b/config.go @@ -328,6 +328,11 @@ func ValidateConfig(app *ApplicationContext) error { } } + // Notify + if app.Config.Notify.Interval == 0 { + app.Config.Notify.Interval = 10 + } + // SMTP server config if app.Config.Smtp.Server != "" { if !validateHostname(app.Config.Smtp.Server) { @@ -356,11 +361,6 @@ func ValidateConfig(app *ApplicationContext) error { } // Username and password are not validated - they're optional - // Notify - if app.Config.Notify.Interval == 0 { - app.Config.Notify.Interval = 10 - } - // Email configs for email, cfg := range app.Config.Emailnotifier { if !validateEmail(email) {