You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2019/03/12 16:20:55 UTC

[lucene-solr] branch branch_8x updated: LUCENE-8720: fix int overflow in NameIntCacheLRU

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new c9de94c  LUCENE-8720: fix int overflow in NameIntCacheLRU
c9de94c is described below

commit c9de94c66333fa3adfd0878ca6d38e05faff1738
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Tue Mar 12 12:19:33 2019 -0400

    LUCENE-8720: fix int overflow in NameIntCacheLRU
---
 lucene/CHANGES.txt                                                    | 3 +++
 .../lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java     | 2 +-
 .../org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 06ff6b5..41b46d8 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -10,6 +10,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
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java
index bab29f6..68588c5 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java
@@ -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();
     }
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java
index 25f2799..29f6fad 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java
@@ -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;
     }