Skip to content

Commit 8ea107c

Browse files
authored
[ISSUE apache#1018] Fix unintended shutdown of shared rmqClient
caused by missing ref count
1 parent 1c6598f commit 8ea107c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

internal/client.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package internal
1919

2020
import (
2121
"context"
22-
"errors"
2322
"fmt"
2423
"net"
2524
"os"
@@ -385,10 +384,8 @@ func GetOrNewRocketMQClient(option ClientOptions, callbackCh chan interface{}) R
385384
func (c *rmqClient) Start() {
386385
//ctx, cancel := context.WithCancel(context.Background())
387386
//c.cancel = cancel
387+
atomic.AddInt32(&c.instanceCount, 1)
388388
c.once.Do(func() {
389-
390-
atomic.AddInt32(&c.instanceCount, 1)
391-
392389
if !c.option.Credentials.IsEmpty() {
393390
c.remoteClient.RegisterInterceptor(remote.ACLInterceptor(c.option.Credentials))
394391
}
@@ -704,7 +701,7 @@ func (c *rmqClient) ProcessSendResponse(brokerName string, cmd *remote.RemotingC
704701
case ResSuccess:
705702
status = primitive.SendOK
706703
default:
707-
return errors.New(fmt.Sprintf("CODE: %d, DESC: %s", cmd.Code, cmd.Remark))
704+
return fmt.Errorf("CODE: %d, DESC: %s", cmd.Code, cmd.Remark)
708705
}
709706

710707
msgIDs := make([]string, 0)

0 commit comments

Comments
 (0)