madelson / DistributedLock

A .NET library for distributed synchronization
MIT License
1.86k stars 192 forks source link

ExtensionCadence throws error when trying to pass in Timeout.InfiniteTimeSpan #131

Closed Skier23 closed 2 years ago

Skier23 commented 2 years ago

When trying to pass in Timeout.InfiniteTimeSpan to RedisDistributedSynchronizationOptionsBuilder.ExtensionCadence, I get an error message: extensionCadence must be less than expiry 00:00:01. To disable auto-extension, specify Timeout.InfiniteTimeSpan...

Skier23 commented 2 years ago

It looks like this line (148) of RedisSynchronizationOptionsBuilder.cs: if (specifiedExtensionCadence.CompareTo(minValidityTime) >= 0)

should be:

if (!specifiedExtensionCadence.IsInfinite && specifiedExtensionCadence.CompareTo(expiry) >= 0)

madelson commented 2 years ago

Hi @Skier23 thanks for filing.

This is a real bug and actually a duplicate of #130 . Therefore, I'm going to close. Something I'd like to understand is your reason for wanting to disable auto-extension; if you view the discussion on the linked issue you can see that we determined that this wasn't actually the right course of action for the OP's use-case. Would you mind commenting about your use-case on #130 ?. Thanks!