Fixed cache bug

This commit is contained in:
Andrea Cavalli 2019-04-20 23:04:05 +02:00
parent bf40dd7787
commit 4901f2fd4c

View File

@ -81,13 +81,14 @@ public class DatabaseReferencesMetadataCache {
if (closed) throw new IOException("Cache already closed!");
lock.writeLock().lock();
try {
for (int i = 0; i < references.length; i++) {
if (cleanerIds[i] == 0) {
throw new IOException("Null cleaner id");
}
}
Long2LongMap referencesBlocksToAdd = new Long2LongLinkedOpenHashMap(references, blockIds, 0.5f);
Long2ByteMap referencesCleanersToAdd = new Long2ByteLinkedOpenHashMap(references, cleanerIds, 0.5f);
for (int i = 0; i < references.length; i++) {
if (cleanerIds[i] == 0) {
referencesBlocksToAdd.remove(references[i]);
referencesCleanersToAdd.remove(references[i]);
}
}
references2Blocks.putAll(referencesBlocksToAdd);
referencesCleaners.putAll(referencesCleanersToAdd);
flush();