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:19:46 UTC

[lucene-solr] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


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

commit c1bea96cf9c6929be717306f04b9b467e58de68d
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 27ba1ed..9549531 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -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
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;
     }