Skip to content

Commit

Permalink
Fix bug in needAck
Browse files Browse the repository at this point in the history
needAck has reverse logic for checking single subject-single filter
scenario.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Mar 31, 2023
1 parent 6ced966 commit 10b790e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/consumer.go
Expand Up @@ -2569,9 +2569,9 @@ func (o *consumer) isFiltered() bool {
// `isFiltered` need to be performant, so we do
// as any checks as possible to avoid unnecessary work.
// Here we avoid iteration over slices if there is only one subject in stream
// and one equal filter for the consumer.
if len(mset.cfg.Subjects) == 1 && len(o.subjf) == 1 && mset.cfg.Subjects[0] == o.subjf[0].subject {
return true
// and one filter for the consumer.
if len(mset.cfg.Subjects) == 1 && len(o.subjf) == 1 {
return mset.cfg.Subjects[0] != o.subjf[0].subject
}

// if the list is not equal length, we can return early, as this is filtered.
Expand Down

0 comments on commit 10b790e

Please sign in to comment.