mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
fix longSize() implementation for closed map
This commit is contained in:
@@ -131,7 +131,7 @@ public class VanillaChronicleMap<K, V, R>
|
||||
|
||||
alignment = wireIn.read(() -> "alignment").int32();
|
||||
worstAlignment = wireIn.read(() -> "worstAlignment").int32();
|
||||
maxBloatFactor = wireIn.read(() -> "maxBloatFactor").float64();
|
||||
maxBloatFactor = wireIn.read(() -> "maxBloatFactor").float64();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,12 +203,13 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public final long longSize() {
|
||||
long result = 0L;
|
||||
try (IterationContext<K, V, ?> c = iterationContext()) {
|
||||
for (int segmentIndex = 0; segmentIndex < segments(); segmentIndex++) {
|
||||
c.initSegmentIndex(segmentIndex);
|
||||
result += c.size();
|
||||
if (!isClosed())
|
||||
try (IterationContext<K, V, ?> c = iterationContext()) {
|
||||
for (int segmentIndex = 0; segmentIndex < segments(); segmentIndex++) {
|
||||
c.initSegmentIndex(segmentIndex);
|
||||
result += c.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user