Fix consumer info if consumer was closed (#4610)

Co-authored-by: Derek Collison <derek@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-09-29 13:47:55 -07:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -2493,7 +2493,7 @@ func (o *consumer) infoWithSnap(snap bool) *ConsumerInfo {
func (o *consumer) infoWithSnapAndReply(snap bool, reply string) *ConsumerInfo {
o.mu.Lock()
mset := o.mset
if mset == nil || mset.srv == nil {
if o.closed || mset == nil || mset.srv == nil {
o.mu.Unlock()
return nil
}

View File

@@ -4286,7 +4286,13 @@ func (s *Server) jsConsumerInfoRequest(sub *subscription, c *client, _ *Account,
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
return
}
resp.ConsumerInfo = obs.info()
if resp.ConsumerInfo = obs.info(); resp.ConsumerInfo == nil {
// This consumer returned nil which means it's closed. Respond with not found.
resp.Error = NewJSConsumerNotFoundError()
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
return
}
s.sendAPIResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(resp))
}