WebOptimizer
WebOptimizer copied to clipboard
FileVersionProvider shared between all assets - Wrong FileProvider may be used
The _fileversionprovider variable is static in the Asset class, and it's initialized off the FIRST call to GenerateCacheKey using the current asset's FileProvider.
Everything is okay as long as you don't have a custom file provider, but if an individual asset has a custom file provider it is ONLY used if the static "_fileVersionProvider" variable is NULL.
Also, no thread safety around setting this, but it shouldn't be static anyway.
Everything is okay as long as you don't have a custom file provider...
Not always. I am using the standard file provider but tried to launch a new Kestrel instance within the same process for each set of automated tests. For every test after the first the result was
Microsoft.Extensions.Caching.Memory.MemoryCache.CheckDisposed()
Microsoft.Extensions.Caching.Memory.MemoryCache.TryGetValue(object key, out object result)
Microsoft.Extensions.Caching.Memory.CacheExtensions.TryGetValue<TItem>(IMemoryCache cache, object key, out TItem value)
WebOptimizer.FileVersionProvider.AddFileVersionToPath(string path)
WebOptimizer.Asset.GenerateCacheKey(HttpContext context)
WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options)
WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)