apache / apache/servicecomb-java-chassis
addLocalContext(parentContext.getLocalContext());多线程问题Concurrentmodificationexception Bug
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 814
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 1
Description
这个类有构造这个代码:
org.apache.servicecomb.swagger.invocation.SwaggerInvocation#SwaggerInvocation
public SwaggerInvocation() {
parentContext = ContextUtils.getInvocationContext();
if (parentContext != null) {
addContext(parentContext.getContext());
addLocalContext(parentContext.getLocalContext());
}
}
其中addLocalContext(parentContext.getLocalContext()); 里面调用了localContext.putAll(otherContext);
这个在多线程环境,业务代码自己开多线程调用下游服务传递上下文会有多线程问题,报Concurrentmodificationexception异常
建议使用public void setLocalContext(Map localContext)直接设置上下文
或者将
protected Map context = new HashMap<>();
protected Map localContext = new HashMap<>();
都换成ConcurrentMap
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.