Skip to content

Commit

Permalink
[FIXED] Nil pointer when sub is nil in service API err handler (#1371)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio authored Sep 12, 2023
1 parent 3acdc37 commit 7e3e54f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions micro/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ func (s *service) wrapConnectionEventCallbacks() {
s.natsHandlers.asyncErr = s.nc.ErrorHandler()
if s.natsHandlers.asyncErr != nil {
s.nc.SetErrorHandler(func(c *nats.Conn, sub *nats.Subscription, err error) {
if sub == nil {
s.natsHandlers.asyncErr(c, sub, err)
return
}
endpoint, match := s.matchSubscriptionSubject(sub.Subject)
if !match {
s.natsHandlers.asyncErr(c, sub, err)
Expand All @@ -496,6 +500,9 @@ func (s *service) wrapConnectionEventCallbacks() {
})
} else {
s.nc.SetErrorHandler(func(c *nats.Conn, sub *nats.Subscription, err error) {
if sub == nil {
return
}
endpoint, match := s.matchSubscriptionSubject(sub.Subject)
if !match {
return
Expand Down

0 comments on commit 7e3e54f

Please sign in to comment.