Skip to content

Commit

Permalink
Remove confusing error message in Redis options that implied the
Browse files Browse the repository at this point in the history
ability to disable auto-extension.

Fix #130
  • Loading branch information
madelson committed Jul 7, 2022
1 parent bb5f5be commit ab10b00
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ internal static RedisDistributedLockOptions GetOptions(Action<RedisDistributedSy
TimeoutValue extensionCadence;
if (options?._extensionCadence is { } specifiedExtensionCadence)
{
// Note: we do not allow for disabling auto-extension here because it leads to traps
// where people might abandon the handle and then have it be closed due to GC.
// See discussion here: https://github.com/madelson/DistributedLock/issues/130.
if (specifiedExtensionCadence.CompareTo(minValidityTime) >= 0)
{
throw new ArgumentOutOfRangeException(
nameof(extensionCadence),
specifiedExtensionCadence.TimeSpan,
$"{nameof(extensionCadence)} must be less than {nameof(expiry)} ({expiry.TimeSpan}). To disable auto-extension, specify {nameof(Timeout)}.{nameof(Timeout.InfiniteTimeSpan)}"
$"{nameof(extensionCadence)} must be less than {nameof(expiry)} ({expiry.TimeSpan})"
);
}
extensionCadence = specifiedExtensionCadence;
Expand Down

0 comments on commit ab10b00

Please sign in to comment.