diff --git a/internal/server/event_server.go b/internal/server/event_server.go index 8183a8312..aa9a0b38c 100644 --- a/internal/server/event_server.go +++ b/internal/server/event_server.go @@ -114,7 +114,11 @@ func (s *EventServer) eventMiddleware(h http.Handler) http.Handler { w.WriteHeader(http.StatusBadRequest) return } - r.Body.Close() + if err := r.Body.Close(); err != nil { + s.logger.Error(err, "closing the request body failed") + w.WriteHeader(http.StatusBadRequest) + return + } r.Body = io.NopCloser(bytes.NewBuffer(body)) event := &eventv1.Event{} diff --git a/internal/server/receiver_handler_test.go b/internal/server/receiver_handler_test.go index 35d317dce..c72ff0057 100644 --- a/internal/server/receiver_handler_test.go +++ b/internal/server/receiver_handler_test.go @@ -677,7 +677,7 @@ func Test_handlePayload(t *testing.T) { g.Expect(rr.Result().StatusCode).To(gomega.Equal(tt.expectedResponseCode)) var allReceivers apiv1.ReceiverList - err = client.List(context.TODO(), &allReceivers) + g.Expect(client.List(context.TODO(), &allReceivers)).To(gomega.Succeed()) var annotatedResources int for _, obj := range allReceivers.Items {