This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b76c4554 fix: etcd data sync exception (#8493)
3b76c4554 is described below

commit 3b76c45543861a0fb4a7924842d3a47c51ae83b2
Author: CuttleFish <[email protected]>
AuthorDate: Tue Mar 21 09:52:27 2023 +0800

    fix: etcd data sync exception (#8493)
    
    Co-authored-by: 80317381 <[email protected]>
---
 apisix/core/config_util.lua | 4 ++++
 t/core/config_util.t        | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/apisix/core/config_util.lua b/apisix/core/config_util.lua
index b3fb13b7c..4cc0ed33d 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 2b012fc97..6d9e1e2f8 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

Reply via email to