Skip to content

Commit

Permalink
[ISSUE #884]fix goroutine leak (#885)
Browse files Browse the repository at this point in the history
* [ISSUE #884]fix goroutine leak

* mock UnregisterConsumer
  • Loading branch information
Nick authored Aug 6, 2022
1 parent 3ccfbff commit 43edd17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion consumer/push_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (pc *pushConsumer) Start() error {
for k := range pc.subscribedTopic {
_, exist := pc.topicSubscribeInfoTable.Load(k)
if !exist {
pc.client.Shutdown()
pc.Shutdown()
return fmt.Errorf("the topic=%s route info not found, it may not exist", k)
}
}
Expand Down
4 changes: 3 additions & 1 deletion consumer/push_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package consumer

import (
"context"
"github.com/apache/rocketmq-client-go/v2/rlog"
"testing"

"github.com/apache/rocketmq-client-go/v2/rlog"

"github.com/apache/rocketmq-client-go/v2/internal"
"github.com/apache/rocketmq-client-go/v2/primitive"
"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -80,6 +81,7 @@ func TestStart(t *testing.T) {

Convey("test topic route info not found", func() {
client.EXPECT().Shutdown().Return()
client.EXPECT().UnregisterConsumer(gomock.Any()).Return()
err = c.Start()
So(err.Error(), ShouldContainSubstring, "route info not found")
})
Expand Down

0 comments on commit 43edd17

Please sign in to comment.