From 9ebe8094a88cd7bd7fde9fbea88ec675a71d1614 Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Fri, 19 Feb 2021 10:47:43 +0100 Subject: [PATCH] :lipstick: adding check for -1 status code for the default impl Signed-off-by: Matthias Wessendorf --- pkg/kncloudevents/message_sender.go | 2 +- pkg/kncloudevents/message_sender_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kncloudevents/message_sender.go b/pkg/kncloudevents/message_sender.go index bb0127e55af..a2be82b2082 100644 --- a/pkg/kncloudevents/message_sender.go +++ b/pkg/kncloudevents/message_sender.go @@ -162,7 +162,7 @@ func RetryConfigFromDeliverySpec(spec duckv1.DeliverySpec) (RetryConfig, error) // Simple default implementation func RetryIfGreaterThan300(_ context.Context, response *nethttp.Response, err error) (bool, error) { - return !(response != nil && (response.StatusCode < 300)), err + return !(response != nil && (response.StatusCode < 300 && response.StatusCode != -1)), err } // Alternative function to determine whether to retry based on response diff --git a/pkg/kncloudevents/message_sender_test.go b/pkg/kncloudevents/message_sender_test.go index 6350de01f90..fc07bdddcd0 100644 --- a/pkg/kncloudevents/message_sender_test.go +++ b/pkg/kncloudevents/message_sender_test.go @@ -336,7 +336,7 @@ func TestRetryIfGreaterThan300(t *testing.T) { { name: "Http StatusCode -1", response: &http.Response{StatusCode: -1}, - result: false, + result: true, }, { name: "Http StatusCode 100",