Skip to content

Commit

Permalink
Merge pull request #2427 from nats-io/bad-err
Browse files Browse the repository at this point in the history
Fix for #2423
  • Loading branch information
derekcollison authored Aug 10, 2021
2 parents 6f4cc20 + cb6b397 commit b38c361
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (mset *stream) addConsumerWithAssignment(config *ConsumerConfig, oname stri
return nil, ApiErrors[JSConsumerDeliverCycleErr]
}
if config.MaxWaiting != 0 {
return nil, ApiErrors[JSConsumerDeliverToWildcardsErr]
return nil, ApiErrors[JSConsumerPushMaxWaitingErr]
}
if config.MaxAckPending > 0 && config.AckPolicy == AckNone {
return nil, ApiErrors[JSConsumerMaxPendingAckPolicyRequiredErr]
Expand Down
37 changes: 37 additions & 0 deletions server/jetstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12551,6 +12551,43 @@ func TestJetStreamConsumerPendingBugWithKV(t *testing.T) {
}
}

// Issue #2423
func TestJetStreamBadConsumerCreateErr(t *testing.T) {
s := RunBasicJetStreamServer()
defer s.Shutdown()

if config := s.JetStreamConfig(); config != nil {
defer removeDir(t, config.StoreDir)
}

// Client for API requests.
nc, js := jsClientConnect(t, s)
defer nc.Close()

_, err := js.AddStream(&nats.StreamConfig{
Name: "TEST",
Subjects: []string{"foo.*"},
Storage: nats.MemoryStorage,
})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}

// When adding a consumer with both deliver subject and max wait (push vs pull),
// we got the wrong err about deliver subject having a wildcard.
_, err = js.AddConsumer("TEST", &nats.ConsumerConfig{
Durable: "nowcerr",
DeliverSubject: "X",
MaxWaiting: 100,
})
if err == nil {
t.Fatalf("Expected an error but got none")
}
if !strings.Contains(err.Error(), "push mode can not set max waiting") {
t.Fatalf("Incorrect error returned: %v", err)
}
}

///////////////////////////////////////////////////////////////////////////
// Simple JetStream Benchmarks
///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b38c361

Please sign in to comment.