You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens because method call invocation logic inside Interceptor is not thread safe. When Interceptor.Intercept method is called it creates strategy pipeline, one of strategies in this pipeline - ExtractProxyCall - locates matched method call and places it into InterceptStrategyContext.CurrentCall. Which is later used by ExecuteCall strategy to do the actual call.
The problem here is that both executing threads will work with same InterceptorContext instance. So when executed in parallel it's possible of one ExtractProxyCall strategy to overwrite method call just located by another ExtractProxyCall strategy, that way both ExecuteCall strategies will end up executing same method call twice. This can easily be confirmed by attaching callbacks to original setups.
mock.Verify(x => ...) on the other hand does verification evaluating given expression against collected call contexts which, obviously, contains correct information.
The text was updated successfully, but these errors were encountered:
@VitaliyKurokhtin: I am closing this issue as I strongly suspect that this has been fixed long ago (possibly by commit 1948508). Most of what you mentioned above no longer exists today in the same form. For instance, InterceptStrategyContext.CurrentCall appears to have been refactored into CurrentInterceptorContext.Call, and each interception works with a different copy of that.
I tried reproducing this issue (but didn't succeed).
Just came across following issue with Moq (4.2.1312.1622). Consider interface:
... setup:
... and invocation:
Every now and then this verification will fail saying that one of two setups was not matched. But will succeed if changed to:
This happens because method call invocation logic inside Interceptor is not thread safe. When Interceptor.Intercept method is called it creates strategy pipeline, one of strategies in this pipeline - ExtractProxyCall - locates matched method call and places it into InterceptStrategyContext.CurrentCall. Which is later used by ExecuteCall strategy to do the actual call.
The problem here is that both executing threads will work with same InterceptorContext instance. So when executed in parallel it's possible of one ExtractProxyCall strategy to overwrite method call just located by another ExtractProxyCall strategy, that way both ExecuteCall strategies will end up executing same method call twice. This can easily be confirmed by attaching callbacks to original setups.
mock.Verify(x => ...) on the other hand does verification evaluating given expression against collected call contexts which, obviously, contains correct information.
The text was updated successfully, but these errors were encountered: