From f5c7d90d2fb56aaa004466ce34638b7caef6056b Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 25 Feb 2015 23:24:33 +0000 Subject: [PATCH] LUCENE-6297: make sure default LogByteSizeMP.getMaxMergeMBForForcedMerge is > 0.0 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662325 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/index/LogByteSizeMergePolicy.java | 1 + .../src/test/org/apache/lucene/index/TestLogMergePolicy.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lucene/core/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java index 1d077f42752..9e92455b92c 100644 --- a/lucene/core/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java @@ -39,6 +39,7 @@ public class LogByteSizeMergePolicy extends LogMergePolicy { public LogByteSizeMergePolicy() { minMergeSize = (long) (DEFAULT_MIN_MERGE_MB*1024*1024); maxMergeSize = (long) (DEFAULT_MAX_MERGE_MB*1024*1024); + // NOTE: in Java, if you cast a too-large double to long, as we are doing here, then it becomes Long.MAX_VALUE maxMergeSizeForForcedMerge = (long) (DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE*1024*1024); } diff --git a/lucene/core/src/test/org/apache/lucene/index/TestLogMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestLogMergePolicy.java index 0be5bb91fa3..8dffdf88851 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestLogMergePolicy.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestLogMergePolicy.java @@ -23,4 +23,8 @@ public class TestLogMergePolicy extends BaseMergePolicyTestCase { return newLogMergePolicy(random()); } + public void testDefaultForcedMergeMB() { + LogByteSizeMergePolicy mp = new LogByteSizeMergePolicy(); + assertTrue(mp.getMaxMergeMBForForcedMerge() > 0.0); + } }