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

Thread safety of RazorEngine.ErrorMessage #40

Open
v1k7-992 opened this issue Jul 22, 2020 · 0 comments
Open

Thread safety of RazorEngine.ErrorMessage #40

v1k7-992 opened this issue Jul 22, 2020 · 0 comments

Comments

@v1k7-992
Copy link

Hi, if we have an application that is using any derived type from RazorTemplateBase, and using the application wrapper as described in the documentation (link to doc), for instance, if there would be a case where two threads try generating output based on a template, with different model data, if one thread for instance fails, and the other passes, that might result in a case where the ErrorMessage string would potentially be overwritten to null for the thread that failed, or it would have been overwritten with incorrect error message in the thread that succeeded in making a valid response? And then when accessing ErrorMessage we might not be able to access the reason why template generation failed.

This is all theoretical and I haven't observed such a a situation when using this library so far.

What would you suggest to be able to avoid such thread safety issues that might occur?
I am thinking of two things:

  • Either using all the HostContainers in a Object pool
  • Or maybe wrapping ErrorMessage in a lock statement?

In any case, thanks for any feedback provided.

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