Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mqtt): conn subs npe #3415

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions internal/io/mqtt/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type Connection struct {
status atomic.Value
scHandler api.StatusChangeHandler
// key is the topic. Each topic will have only one connector map[string]*client.SubscriptionInfo
subscriptions *sync.Map
subscriptions sync.Map
}

func CreateConnection(_ api.StreamContext) modules.Connection {
return &Connection{
subscriptions: new(sync.Map),
subscriptions: sync.Map{},
}
}

Expand Down Expand Up @@ -155,9 +155,7 @@ func (conn *Connection) DetachSub(ctx api.StreamContext, props map[string]any) {
ctx.GetLogger().Warnf("cannot find topic to unsub: %v", props)
return
}
if conn.subscriptions != nil {
conn.subscriptions.Delete(topic)
}
conn.subscriptions.Delete(topic)
if conn.Client != nil {
err = conn.Client.Unsubscribe(ctx, topic)
if err != nil {
Expand Down
Loading