From 41850629095e5048d9702f9ed3d51154b470f77f Mon Sep 17 00:00:00 2001
From: wangxw <2484713618@qq.com>
Date: Fri, 12 Nov 2021 12:46:43 +0800
Subject: [PATCH] graceful shutdwon filter (#1585)

Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>
---
 filter/gshutdown/filter.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go
index 6d2b9602b..f2c3bae60 100644
--- a/filter/gshutdown/filter.go
+++ b/filter/gshutdown/filter.go
@@ -33,11 +33,13 @@ import (
 
 func init() {
 	// `init()` is performed before config.Load(), so shutdownConfig will be retrieved after config was loaded.
+	var csf = &Filter{}
+	var psf = &Filter{}
 	extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter {
-		return &Filter{}
+		return csf
 	})
 	extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter {
-		return &Filter{}
+		return psf
 	})
 }
 
@@ -69,7 +71,7 @@ func (f *Filter) OnResponse(ctx context.Context, result protocol.Result, invoker
 func (f *Filter) Set(name string, conf interface{}) {
 	switch name {
 	case constant.GracefulShutdownFilterShutdownConfig:
-		if shutdownConfig, ok := conf.(*config.ShutdownConfig); !ok {
+		if shutdownConfig, ok := conf.(*config.ShutdownConfig); ok {
 			f.shutdownConfig = shutdownConfig
 			return
 		}
-- 
GitLab