提交 ddf9c813 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not assign invalid new SoftReference<>(null) to Value.softCache

上级 5a7618d5
...@@ -179,8 +179,7 @@ public abstract class Value { ...@@ -179,8 +179,7 @@ public abstract class Value {
*/ */
public static final int TYPE_COUNT = ENUM; public static final int TYPE_COUNT = ENUM;
private static SoftReference<Value[]> softCache = private static SoftReference<Value[]> softCache;
new SoftReference<>(null);
private static final BigDecimal MAX_LONG_DECIMAL = private static final BigDecimal MAX_LONG_DECIMAL =
BigDecimal.valueOf(Long.MAX_VALUE); BigDecimal.valueOf(Long.MAX_VALUE);
private static final BigDecimal MIN_LONG_DECIMAL = private static final BigDecimal MIN_LONG_DECIMAL =
...@@ -396,11 +395,8 @@ public abstract class Value { ...@@ -396,11 +395,8 @@ public abstract class Value {
static Value cache(Value v) { static Value cache(Value v) {
if (SysProperties.OBJECT_CACHE) { if (SysProperties.OBJECT_CACHE) {
int hash = v.hashCode(); int hash = v.hashCode();
if (softCache == null) { Value[] cache;
softCache = new SoftReference<>(null); if (softCache == null || (cache = softCache.get()) == null) {
}
Value[] cache = softCache.get();
if (cache == null) {
cache = new Value[SysProperties.OBJECT_CACHE_SIZE]; cache = new Value[SysProperties.OBJECT_CACHE_SIZE];
softCache = new SoftReference<>(cache); softCache = new SoftReference<>(cache);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论