diff --git a/apisix/core/config_util.lua b/apisix/core/config_util.lua index b3fb13b7cce5..4cc0ed33daf3 100644 --- a/apisix/core/config_util.lua +++ b/apisix/core/config_util.lua @@ -96,6 +96,10 @@ end -- fire all clean handlers added by add_clean_handler. function _M.fire_all_clean_handlers(item) + -- When the key is deleted, the item will be set to false. + if not item then + return + end if not item.clean_handlers then return end diff --git a/t/core/config_util.t b/t/core/config_util.t index 2b012fc97be0..6d9e1e2f8fce 100644 --- a/t/core/config_util.t +++ b/t/core/config_util.t @@ -89,6 +89,11 @@ __DATA__ return item, idx1, idx2 end + local function setup_to_false() + local item = false + return item + end + local item, idx1, idx2 = setup() util.cancel_clean_handler(item, idx1, true) util.cancel_clean_handler(item, idx2, true) @@ -103,6 +108,9 @@ __DATA__ local item, idx1, idx2 = setup() util.cancel_clean_handler(item, idx1) util.fire_all_clean_handlers(item) + + local item = setup_to_false() + util.fire_all_clean_handlers(item) } } --- grep_error_log eval