diff --git a/server/accounts.go b/server/accounts.go index 052abb2a..6ddfa04c 100644 --- a/server/accounts.go +++ b/server/accounts.go @@ -489,15 +489,7 @@ func (a *Account) TotalSubs() int { // for the given `subject`. Works only for literal subjects. // TODO: Add support for wildcards func (a *Account) SubscriptionInterest(subject string) bool { - var interest bool - a.mu.RLock() - if a.sl != nil { - if res := a.sl.Match(subject); len(res.psubs)+len(res.qsubs) > 0 { - interest = true - } - } - a.mu.RUnlock() - return interest + return a.Interest(subject) > 0 } // Interest returns the number of subscriptions for a given subject that match. diff --git a/server/leafnode_test.go b/server/leafnode_test.go index 29177e63..0555908b 100644 --- a/server/leafnode_test.go +++ b/server/leafnode_test.go @@ -1639,6 +1639,7 @@ func TestLeafNodeOriginClusterInfo(t *testing.T) { // Make sure we disconnect and reconnect. checkLeafNodeConnectedCount(t, s, 0) checkLeafNodeConnected(t, s) + checkLeafNodeConnected(t, hub) l = grabLeaf() if rc := l.remoteCluster(); rc != "xyz" { diff --git a/test/leafnode_test.go b/test/leafnode_test.go index 363bc019..739a0cb2 100644 --- a/test/leafnode_test.go +++ b/test/leafnode_test.go @@ -3986,7 +3986,7 @@ func TestLeafNodeOriginCluster(t *testing.T) { defer nc3.Close() wcSubj := "foo.*" - nc3.SubscribeSync(wcSubj) + wcsub, _ := nc3.SubscribeSync(wcSubj) // This is a placeholder that we can use to check all interest has propagated. nc3.SubscribeSync("bar") waitForInterest("bar", ln1, ln2, ln3, ca.servers[0], ca.servers[1], ca.servers[2]) @@ -4006,6 +4006,11 @@ func TestLeafNodeOriginCluster(t *testing.T) { if n, _, _ := sub.Pending(); n != 1 { t.Fatalf("Expected only one message, got %d", n) } + // Also for wc + if n, _, _ := wcsub.Pending(); n != 1 { + t.Fatalf("Expected only one message, got %d", n) + } + // grab the msg msg, _ := sub.NextMsg(time.Second) if !bytes.Equal(m.Data, msg.Data) {