LUCENE-8720: fix int overflow in NameIntCacheLRU

This commit is contained in:
Mike McCandless 2019-03-12 12:19:33 -04:00
parent 9edc557f45
commit c1bea96cf9
3 changed files with 6 additions and 3 deletions

View File

@ -22,6 +22,9 @@ Bug fixes
* LUCENE-8712: Polygon2D does not detect crossings through segment edges.
(Ignacio Vera)
* LUCENE-8720: NameIntCacheLRU (in the facets module) had an int
overflow bug that disabled cleaning of the cache (Russell A Brown)
Improvements
* LUCENE-8673: Use radix partitioning when merging dimensional points instead

View File

@ -112,7 +112,7 @@ public class LruTaxonomyWriterCache implements TaxonomyWriterCache {
// visible to us we need to make sure that the changes have been
// committed and we reopen the reader. Because this is a slow
// operation, we don't delete entries one-by-one but rather in bulk
// (put() removes the 2/3rd oldest entries).
// (put() removes the 1/3rd oldest entries).
if (ret) {
cache.makeRoomLRU();
}

View File

@ -109,13 +109,13 @@ class NameIntCacheLRU {
* if anything was removed, false otherwise.
*
* See comment in DirectoryTaxonomyWriter.addToCache(CategoryPath, int) for an
* explanation why we clean 2/3rds of the cache, and not just one entry.
* explanation why we clean 1/3rd of the cache, and not just one entry.
*/
boolean makeRoomLRU() {
if (!isCacheFull()) {
return false;
}
int n = cache.size() - (2*maxCacheSize)/3;
int n = cache.size() - (int)((2L*maxCacheSize)/3);
if (n<=0) {
return false;
}