Skip to content

Commit

Permalink
add check for LockUntil field
Browse files Browse the repository at this point in the history
  • Loading branch information
karenychen committed Aug 5, 2024
1 parent 0afa328 commit 51d950d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions v2/lockrenewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ func (plr *peekLockRenewer) startPeriodicRenewal(ctx context.Context, message *a

func (plr *peekLockRenewer) renewMessageLock(ctx context.Context, message *azservicebus.ReceivedMessage, options *azservicebus.RenewMessageLockOptions) error {
lockLostErr := &azservicebus.Error{Code: azservicebus.CodeLockLost}
renewalTimeout := time.Until(*message.LockedUntil) // assumes messages.LockedUntil is set
if renewalTimeout < 0 {
// if the lock is already expired, we should not attempt to renew it.
if message.LockedUntil == nil || time.Until(*message.LockedUntil) < 0 {
// if the lock doesn't exist or is already expired, we should not attempt to renew it.
return lockLostErr
}
renewalTimeout := time.Until(*message.LockedUntil)
if *plr.renewalTimeout > 0 {
renewalTimeout = *plr.renewalTimeout
}
Expand Down

0 comments on commit 51d950d

Please sign in to comment.