提交 32f71bb2 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Issue #231: Possible infinite loop when initializing the ObjectDataType class

上级 b9d25f10
...@@ -21,7 +21,8 @@ Change Log ...@@ -21,7 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>- <li>Issue #231: Possible infinite loop when initializing the ObjectDataType class
when concurrently writing into MVStore.
</li> </li>
</ul> </ul>
......
...@@ -332,8 +332,13 @@ public class ObjectDataType implements DataType { ...@@ -332,8 +332,13 @@ public class ObjectDataType implements DataType {
HashMap<Class<?>, Integer> map = COMMON_CLASSES_MAP; HashMap<Class<?>, Integer> map = COMMON_CLASSES_MAP;
if (map.size() == 0) { if (map.size() == 0) {
// lazy initialization // lazy initialization
// synchronized, because the COMMON_CLASSES_MAP is not
synchronized (map) {
if (map.size() == 0) {
for (int i = 0, size = COMMON_CLASSES.length; i < size; i++) { for (int i = 0, size = COMMON_CLASSES.length; i < size; i++) {
COMMON_CLASSES_MAP.put(COMMON_CLASSES[i], i); map.put(COMMON_CLASSES[i], i);
}
}
} }
} }
return map.get(clazz); return map.get(clazz);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论