You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@GuardedBy("Segment.this")
void evictEntries() {
if (!map.evictsBySize()) {
return;
}
drainRecencyQueue();
while (totalWeight > maxSegmentWeight) {
ReferenceEntry<K, V> e = getNextEvictable();
if (!removeEntry(e, e.getHash(), RemovalCause.SIZE)) {
throw new AssertionError();
}
}
}
'totalWeight' is defined as an int, while 'maxSegmentWeight' is a long. If 'maxSegmentWeight' is set to any value int.MAX_VALUE or greater, then this check
while (totalWeight > maxSegmentWeight) {
will never be true, since 'totalWeight' will overflow, and the eviction code will never run.
The text was updated successfully, but these errors were encountered:
Original issue created by DanGLow on 2014-05-22 at 05:18 PM
Hi,
This bug was originally discovered here: elastic/elasticsearch#6268, but I have traced it down into an issue with an overflowing int and long comparison in LocalCache.java eviction logic. The following is the eviction code at https://github.com/google/guava/blob/master/guava/src/com/google/common/cache/LocalCache.java#L2665
@GuardedBy("Segment.this")
void evictEntries() {
if (!map.evictsBySize()) {
return;
}
drainRecencyQueue();
while (totalWeight > maxSegmentWeight) {
ReferenceEntry<K, V> e = getNextEvictable();
if (!removeEntry(e, e.getHash(), RemovalCause.SIZE)) {
throw new AssertionError();
}
}
}
'totalWeight' is defined as an int, while 'maxSegmentWeight' is a long. If 'maxSegmentWeight' is set to any value int.MAX_VALUE or greater, then this check
while (totalWeight > maxSegmentWeight) {
will never be true, since 'totalWeight' will overflow, and the eviction code will never run.
The text was updated successfully, but these errors were encountered: