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

EndpointUserConfig.AddEndpoint方法存在并发问题 #396

Open
colin-chang opened this issue May 20, 2021 · 0 comments
Open

EndpointUserConfig.AddEndpoint方法存在并发问题 #396

colin-chang opened this issue May 20, 2021 · 0 comments

Comments

@colin-chang
Copy link

上面代码中 endpoints 使用了非线程安全字典 Dictionary<string, ProductDomain>。在字典中查询key过程中其他线程对字典进行修改会导致InvalidOperationException,异常堆栈信息如下:

System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at Aliyun.Acs.Core.Regions.EndpointUserConfig.AddEndpoint(String product, String regionId, String domain)

建议将 endpoints 类型修改为线程安全的 ConcurrentDictionary<string, ProductDomain> 修复此问题 @AxiosCros

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