Use if not select for context check
@@ -351,11 +351,11 @@ func (s *Subscription) RenewLocksBlocking(ctx context.Context, receiver Receiver
s.logger.Infof("context canceled while renewing locks for %s", s.entity)
return nil
case <-t.C:
- select {
- case <-ctx.Done():
+ // Check if the context is still valid
+ if ctx.Err() != nil {
s.logger.Infof("context canceled while renewing locks for %s", s.entity)
return nil
- default:
+ }
if s.requireSessions {
sessionReceiver := receiver.(*SessionReceiver)
if err := sessionReceiver.RenewSessionLocks(ctx, opts.TimeoutInSec); err != nil {
@@ -384,7 +384,6 @@ func (s *Subscription) RenewLocksBlocking(ctx context.Context, receiver Receiver
}
}
}
-}
// handleAsync handles messages from azure service bus asynchronously.
// runHandlerFn is responsible for calling the message handler function
