1
0
Fork 0

Merge pull request #883 from rqlite/missing-http-returns

Add missing returns after HTTP errors
master
Philip O'Toole 3 years ago committed by GitHub
commit 8cf193bfc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
## 6.4.3 (unreleased) ## 6.4.3 (unreleased)
### Implementation changes and bug fixes ### Implementation changes and bug fixes
- [PR #882](https://github.com/rqlite/rqlite/pull/882): Some minor improvements related to on-disk SQLite use. - [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) ## 6.4.2 (September 1st 2021)
### Implementation changes and bug fixes ### Implementation changes and bug fixes

@ -632,13 +632,13 @@ func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) {
} }
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} else { return
}
_, err = w.Write([]byte(b)) _, err = w.Write([]byte(b))
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
}
} }
// handleNodes returns status on the other voting nodes in the system. // handleNodes returns status on the other voting nodes in the system.
@ -725,13 +725,13 @@ func (s *Service) handleNodes(w http.ResponseWriter, r *http.Request) {
} }
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} else { return
}
_, err = w.Write([]byte(b)) _, err = w.Write([]byte(b))
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
}
} }
// handleExecute handles queries that modify the database. // handleExecute handles queries that modify the database.
@ -794,10 +794,12 @@ func (s *Service) handleExecute(w http.ResponseWriter, r *http.Request) {
addr, err := s.store.LeaderAddr() addr, err := s.store.LeaderAddr()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return
} }
if addr == "" { if addr == "" {
stats.Add(numLeaderNotFound, 1) stats.Add(numLeaderNotFound, 1)
http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable) http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable)
return
} }
results, resultsErr = s.cluster.Execute(er, addr, timeout) results, resultsErr = s.cluster.Execute(er, addr, timeout)
stats.Add(numRemoteExecutions, 1) stats.Add(numRemoteExecutions, 1)
@ -881,10 +883,12 @@ func (s *Service) handleQuery(w http.ResponseWriter, r *http.Request) {
addr, err := s.store.LeaderAddr() addr, err := s.store.LeaderAddr()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return
} }
if addr == "" { if addr == "" {
stats.Add(numLeaderNotFound, 1) stats.Add(numLeaderNotFound, 1)
http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable) http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable)
return
} }
results, resultsErr = s.cluster.Query(qr, addr, timeout) results, resultsErr = s.cluster.Query(qr, addr, timeout)
stats.Add(numRemoteQueries, 1) stats.Add(numRemoteQueries, 1)

Loading…
Cancel
Save