You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2026/05/08 11:57:25 UTC

(rocketmq-clients) branch master updated: fix(client.go): nil pointer exception during close (#1243)

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

RongtongJin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d026ed5 fix(client.go): nil pointer exception during close (#1243)
9d026ed5 is described below

commit 9d026ed53a228ff65a8cef7365dd9be5d0f9adb1
Author: Quan <zs...@foxmail.com>
AuthorDate: Fri May 8 19:57:19 2026 +0800

    fix(client.go): nil pointer exception during close (#1243)
    
    Add nil checks for `consumerService` and `clientManager` in the close flow to prevent nil pointer panics caused by uninitialized objects.
---
 golang/client.go        | 4 +++-
 golang/push_consumer.go | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/golang/client.go b/golang/client.go
index 7aa17635..04ec6657 100644
--- a/golang/client.go
+++ b/golang/client.go
@@ -647,7 +647,9 @@ func (cli *defaultClient) GracefulStop() error {
 		return fmt.Errorf("client has been closed")
 	}
 	cli.notifyClientTermination()
-	cli.clientManager.UnRegisterClient(cli)
+	if cli.clientManager != nil {
+		cli.clientManager.UnRegisterClient(cli)
+	}
 	cli.done <- struct{}{}
 	close(cli.done)
 	cli.clientMeterProvider.Reset(&v2.Metric{
diff --git a/golang/push_consumer.go b/golang/push_consumer.go
index 237ef4b5..a7d1dce9 100644
--- a/golang/push_consumer.go
+++ b/golang/push_consumer.go
@@ -517,7 +517,9 @@ func (pc *defaultPushConsumer) GracefulStop() error {
 	pc.cli.log.Infof("Begin to Shutdown consumption executor, clientId=%s", pc.cli.clientID)
 
 	// step 4
-	pc.consumerService.Shutdown()
+	if pc.consumerService != nil {
+		pc.consumerService.Shutdown()
+	}
 
 	// step 5
 	time.Sleep(time.Second)