[Bug]: InvalidCastException
when multiple threads retrieve pipeline
#2412
Labels
InvalidCastException
when multiple threads retrieve pipeline
#2412
Describe the bug
System.ComponentModel.DataAnnotations.RangeAttribute
is not thread safe.ValidationHelper
does not synchronize access to Validator and is invoked when initializing pipelines. This can lead to occasionalInvalidCastException
when multiple threads retrieve a pipeline for the first time (whileRangeAttribute
is uninitialized).This was previously reported as #2096 but not fixed.
Expected behavior
No exception is thrown.
Actual behavior
No response
Steps to reproduce
It's pretty difficult to reproduce in the registry, due to the specificity of the race condition and the fact that you only get one chance per process to trigger it.
You can simulate it reliably using just the attribute, however.
Example: "25 exceptions encountered (0.0250%)"
Exception(s) (if any)
Polly version
8.5.0
.NET Version
net9.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: