From d3925890b14343d794e8fda88a0369119f901d5b Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Mon, 14 Mar 2016 10:29:43 +0000 Subject: [PATCH] github wh: return from eventHandler when err != nil closes #837 --- plugins/inputs/github_webhooks/github_webhooks.go | 3 +++ plugins/outputs/influxdb/influxdb.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/github_webhooks/github_webhooks.go b/plugins/inputs/github_webhooks/github_webhooks.go index bc3f184be..726eef037 100644 --- a/plugins/inputs/github_webhooks/github_webhooks.go +++ b/plugins/inputs/github_webhooks/github_webhooks.go @@ -73,14 +73,17 @@ func (gh *GithubWebhooks) Stop() { // Handles the / route func (gh *GithubWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() eventType := r.Header["X-Github-Event"][0] data, err := ioutil.ReadAll(r.Body) if err != nil { w.WriteHeader(http.StatusBadRequest) + return } e, err := NewEvent(data, eventType) if err != nil { w.WriteHeader(http.StatusBadRequest) + return } gh.Lock() gh.events = append(gh.events, e) diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go index fca6b1db1..d72a07754 100644 --- a/plugins/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -195,7 +195,7 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error { // If all of the writes failed, create a new connection array so that // i.Connect() will be called on the next gather. if err != nil { - i.conns = make([]client.Client) + i.conns = make([]client.Client, 0) } return err }