From 7c47e220009c8e3cee9dafaa65e0b3fc7ba56b69 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 11 Mar 2022 11:01:29 +0000 Subject: [PATCH] Set fileListCache to null when invalidating. --- .../java/org/qortal/repository/BlockArchiveReader.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/qortal/repository/BlockArchiveReader.java b/src/main/java/org/qortal/repository/BlockArchiveReader.java index 47e4e7fc..b730ef87 100644 --- a/src/main/java/org/qortal/repository/BlockArchiveReader.java +++ b/src/main/java/org/qortal/repository/BlockArchiveReader.java @@ -23,7 +23,7 @@ import java.util.*; public class BlockArchiveReader { private static BlockArchiveReader instance; - private Map> fileListCache = Collections.synchronizedMap(new HashMap<>()); + private Map> fileListCache; private static final Logger LOGGER = LogManager.getLogger(BlockArchiveReader.class); @@ -67,7 +67,7 @@ public class BlockArchiveReader { } public Triple, List> fetchBlockAtHeight(int height) { - if (this.fileListCache.isEmpty()) { + if (this.fileListCache == null || this.fileListCache.isEmpty()) { this.fetchFileList(); } @@ -94,7 +94,7 @@ public class BlockArchiveReader { public Triple, List> fetchBlockWithSignature( byte[] signature, Repository repository) { - if (this.fileListCache.isEmpty()) { + if (this.fileListCache == null || this.fileListCache.isEmpty()) { this.fetchFileList(); } @@ -167,7 +167,7 @@ public class BlockArchiveReader { public byte[] fetchSerializedBlockBytesForSignature(byte[] signature, boolean includeHeightPrefix, Repository repository) { - if (this.fileListCache.isEmpty()) { + if (this.fileListCache == null || this.fileListCache.isEmpty()) { this.fetchFileList(); } @@ -278,7 +278,7 @@ public class BlockArchiveReader { } public void invalidateFileListCache() { - this.fileListCache.clear(); + this.fileListCache = null; } }