Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone file data loading cached exceptions #64

Open
LukeArthurs opened this issue Apr 8, 2024 · 0 comments
Open

Timezone file data loading cached exceptions #64

LukeArthurs opened this issue Apr 8, 2024 · 0 comments

Comments

@LukeArthurs
Copy link

private static readonly Lazy<MemoryStream> LazyData = new(LoadData);

Since everything in the package is static and the the LazyData initialisation uses the default Lazy 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant