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

MDC操作出现ConcurrentModificationException #346

Closed
wangfengchao opened this issue Jan 4, 2022 · 3 comments
Closed

MDC操作出现ConcurrentModificationException #346

wangfengchao opened this issue Jan 4, 2022 · 3 comments
Assignees
Labels
😖 no runnable reproducible demo 😵 please provide a simple runnable demo that reproduce the problem ❓question Further information is requested

Comments

@wangfengchao
Copy link

wangfengchao commented Jan 4, 2022

在程序里把父线程的MDC内容赋值给子线程过程中,出现java.util.ConcurrentModificationException

各位大佬看下是否因为HashMap操作存在并发问题。

image

image

@oldratlee oldratlee added 😖 no runnable reproducible demo 😵 please provide a simple runnable demo that reproduce the problem ❓question Further information is requested labels Jan 4, 2022
@oldratlee
Copy link
Member

oldratlee commented Jan 4, 2022

@wangfengchao 这个MDC看起来是,在你的应用中使用TTL功能的实现逻辑。

对于 并发逻辑 的设计与实现,往往需要有完整的信息,才能对不同的运行路径分析,
进而确定并发的设计与实现 是否合理。

目前只给了些 片段代码实现。

是否因为HashMap操作存在并发问题。

当对象引用被发布到多个线程时(比如因为通过Transmittable),使用不线程安全的集合(HashMap)往往是有问题的。

这是通用的并发设计,可以翻一下已有一些相关 Issue 中的说明,或了解并发主题。

@oldratlee
Copy link
Member

@wangfengchao 给一个可以说明/复现问题的、极简可运行的Demo工程 ❤️;推荐:

有一个可以说明/复现问题的、极简可运行的Demo工程,也可以排除可能的使用上的问题。

@oldratlee
Copy link
Member

@wangfengchao

这个 Issue 先 close;如果有了复现的 demo,随时 reopen 继续讨论。

@oldratlee oldratlee self-assigned this Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😖 no runnable reproducible demo 😵 please provide a simple runnable demo that reproduce the problem ❓question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants