From 9292a36e28c05e5b91ccdbcd7707a576594712ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Efe=20=C3=87etin?= Date: Tue, 10 Oct 2023 09:23:23 +0300 Subject: [PATCH] :bug: bug: fix nil pointer dereference issue on idempotency middleware (#2668) --- middleware/idempotency/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/middleware/idempotency/config.go b/middleware/idempotency/config.go index f6dd8b4917..fee775938d 100644 --- a/middleware/idempotency/config.go +++ b/middleware/idempotency/config.go @@ -77,7 +77,14 @@ var ConfigDefault = Config{ func configDefault(config ...Config) Config { // Return default config if nothing provided if len(config) < 1 { - return ConfigDefault + cfg := ConfigDefault + + cfg.Lock = NewMemoryLock() + cfg.Storage = memory.New(memory.Config{ + GCInterval: cfg.Lifetime / 2, // Half the lifetime interval + }) + + return cfg } // Override default config