Fixed occasional ConcurrentModificationException in the block archive reader.

This commit is contained in:
CalDescent 2022-01-31 21:39:49 +00:00
parent 01e4bf3a77
commit cbe83987d8

View File

@ -145,20 +145,22 @@ public class BlockArchiveReader {
} }
private String getFilenameForHeight(int height) { private String getFilenameForHeight(int height) {
Iterator it = this.fileListCache.entrySet().iterator(); synchronized (this.fileListCache) {
while (it.hasNext()) { Iterator it = this.fileListCache.entrySet().iterator();
Map.Entry pair = (Map.Entry)it.next(); while (it.hasNext()) {
if (pair == null && pair.getKey() == null && pair.getValue() == null) { Map.Entry pair = (Map.Entry) it.next();
continue; if (pair == null && pair.getKey() == null && pair.getValue() == null) {
} continue;
Triple<Integer, Integer, Integer> heightInfo = (Triple<Integer, Integer, Integer>) pair.getValue(); }
Integer startHeight = heightInfo.getA(); Triple<Integer, Integer, Integer> heightInfo = (Triple<Integer, Integer, Integer>) pair.getValue();
Integer endHeight = heightInfo.getB(); Integer startHeight = heightInfo.getA();
Integer endHeight = heightInfo.getB();
if (height >= startHeight && height <= endHeight) { if (height >= startHeight && height <= endHeight) {
// Found the correct file // Found the correct file
String filename = (String) pair.getKey(); String filename = (String) pair.getKey();
return filename; return filename;
}
} }
} }