GeoTimeZone
GeoTimeZone copied to clipboard
Timezone file data loading cached exceptions
https://github.com/mattjohnsonpint/GeoTimeZone/blob/deb5e6cc31430445bab4694c28f76ea98cf6c9ee/src/GeoTimeZone/TimezoneFileReader.cs#L10
Since everything in the package is static and the the LazyData initialisation uses the default Lazy<T> function, when there is an IO issue and the file is not successfully loaded the first time, the exception is also cached and the package will no longer work until the process is restarted.
So this could be done instead:
private static readonly Lazy<MemoryStream> LazyData = new(LoadData, LazyThreadSafetyMode.PublicationOnly);
This allows multiple threads to start the initialization but the first successful thread value will be cached for subsequent Value access. And exceptions are never cached so that would fix the issue entirely as far I can see.