More consistent cache key validation in Remove (#44286)
authorJody Donetti <indastria@gmail.com>
Thu, 5 Nov 2020 14:05:43 +0000 (15:05 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 14:05:43 +0000 (09:05 -0500)
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs

index 9d3c38c..a3d22ca 100644 (file)
@@ -273,10 +273,7 @@ namespace Microsoft.Extensions.Caching.Memory
         /// <inheritdoc />
         public void Remove(object key)
         {
-            if (key == null)
-            {
-                throw new ArgumentNullException(nameof(key));
-            }
+            ValidateCacheKey(key);
 
             CheckDisposed();
             if (_entries.TryRemove(key, out CacheEntry entry))