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