From 83a5041286b969afc86a96f4b1fe68d830373d89 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 22 Nov 2018 17:28:53 +0200 Subject: [PATCH] Update *empty filter --- engine/filters.go | 3 +++ engine/filters_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/engine/filters.go b/engine/filters.go index bfa1ad71e..38d026efc 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -288,6 +288,9 @@ func (fltr *FilterRule) passEmpty(dP config.DataProvider) (bool, error) { } return false, err } + if val == nil { + return true, nil + } rval := reflect.ValueOf(val) if rval.Type().Kind() == reflect.Ptr { if rval.IsNil() { diff --git a/engine/filters_test.go b/engine/filters_test.go index 7394bf856..7c622cd62 100644 --- a/engine/filters_test.go +++ b/engine/filters_test.go @@ -627,6 +627,7 @@ func TestInlineFilterPassFiltersForEvent(t *testing.T) { "EmptySlice": []string{""}, "EmptyMap": map[string]string{"": ""}, "EmptyPtr": &struct{}{}, + "EmptyPtr2": &struct{}{}, "EmptyPtrSlice": &[]string{""}, "EmptyPtrMap": &map[string]string{"": ""}, } @@ -637,6 +638,7 @@ func TestInlineFilterPassFiltersForEvent(t *testing.T) { "EmptySlice": []string{}, "EmptyMap": map[string]string{}, "EmptyPtr": testnil, + "EmptyPtr2": nil, "EmptyPtrSlice": &[]string{}, "EmptyPtrMap": &map[string]string{}, }