Skip to content

Commit

Permalink
Fix NPE (#112999)
Browse files Browse the repository at this point in the history
* Fix NPE

* bump version
  • Loading branch information
wzshiming committed Oct 15, 2022
1 parent 6f579d3 commit 0005364
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/images/agnhost/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.41
2.42
24 changes: 13 additions & 11 deletions test/images/agnhost/no-snat-test-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ func checknosnat(w http.ResponseWriter, req *http.Request) {
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error querying %q, err: %v", url, err)
} else {
body, err := io.ReadAll(resp.Body)
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err)
} else {
// Respond the same status code and body as /checknosnat on the internal Pod
w.WriteHeader(resp.StatusCode)
w.Write(body)
}
return
}
resp.Body.Close()
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err)
return
}

// Respond the same status code and body as /checknosnat on the internal Pod
w.WriteHeader(resp.StatusCode)
w.Write(body)
}

0 comments on commit 0005364

Please sign in to comment.