diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fece3f4..9b7d93f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 6.4.3 (unreleased) ### Implementation changes and bug fixes - [PR #882](https://github.com/rqlite/rqlite/pull/882): Some minor improvements related to on-disk SQLite use. +- [PR #883](https://github.com/rqlite/rqlite/pull/883): Add missing returns after HTTP errors. ## 6.4.2 (September 1st 2021) ### Implementation changes and bug fixes diff --git a/http/service.go b/http/service.go index 2b23ce5a..1b983d60 100644 --- a/http/service.go +++ b/http/service.go @@ -632,12 +632,12 @@ func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) { } if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) - } else { - _, err = w.Write([]byte(b)) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } + return + } + _, err = w.Write([]byte(b)) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return } } @@ -725,12 +725,12 @@ func (s *Service) handleNodes(w http.ResponseWriter, r *http.Request) { } if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) - } else { - _, err = w.Write([]byte(b)) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } + return + } + _, err = w.Write([]byte(b)) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return } } @@ -794,10 +794,12 @@ func (s *Service) handleExecute(w http.ResponseWriter, r *http.Request) { addr, err := s.store.LeaderAddr() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) + return } if addr == "" { stats.Add(numLeaderNotFound, 1) http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable) + return } results, resultsErr = s.cluster.Execute(er, addr, timeout) stats.Add(numRemoteExecutions, 1) @@ -881,10 +883,12 @@ func (s *Service) handleQuery(w http.ResponseWriter, r *http.Request) { addr, err := s.store.LeaderAddr() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) + return } if addr == "" { stats.Add(numLeaderNotFound, 1) http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable) + return } results, resultsErr = s.cluster.Query(qr, addr, timeout) stats.Add(numRemoteQueries, 1)