Skip to content

Commit

Permalink
Merge pull request #4147 from influxdb/httpd-recovery
Browse files Browse the repository at this point in the history
Missing defer in httpd recovery.  fixes #4124
  • Loading branch information
corylanou committed Sep 17, 2015
2 parents 82ec6e5 + 38cb7b4 commit 83d2df1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [#3457](https://github.com/influxdb/influxdb/issues/3457): [0.9.3] cannot select field names with prefix + "." that match the measurement name
- [#4111](https://github.com/influxdb/influxdb/pull/4111): Update pre-commit hook for go vet composites
- [#4136](https://github.com/influxdb/influxdb/pull/4136): Return an error-on-write if target retention policy does not exist. Thanks for the report @ymettier
- [#4124](https://github.com/influxdb/influxdb/issues/4124): Missing defer/recover/panic idiom in HTTPD service

## v0.9.4 [2015-09-14]

Expand Down
14 changes: 9 additions & 5 deletions services/httpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,16 @@ func recovery(inner http.Handler, name string, weblog *log.Logger) http.Handler
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
l := &responseLogger{w: w}

defer func() {
if err := recover(); err != nil {
logLine := buildLogLine(l, r, start)
logLine = fmt.Sprintf(`%s [panic:%s]`, logLine, err)
weblog.Println(logLine)
}
}()

inner.ServeHTTP(l, r)
if err := recover(); err != nil {
logLine := buildLogLine(l, r, start)
logLine = fmt.Sprintf(`%s [err:%s]`, logLine, err)
weblog.Println(logLine)
}
})
}

Expand Down

0 comments on commit 83d2df1

Please sign in to comment.