Skip to content

Apache Lucene open-source search software

LUCENE-7442: MinHashFilter's ctor should validate its args

Steve Rowe36362a2a69a3
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 4f5326ba318..453e6cb9aae 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -53,6 +53,9 @@ Bug Fixes
ArrayIndexOutOfBoundsException exception on large index segments (>1.8B docs)
with large skips. (yonik)
+* LUCENE-7442: MinHashFilter's ctor should validate its args.
+ (Cao Manh Dat via Steve Rowe)
+
Improvements
Optimizations
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
index 772f58ad946..4ddf711212c 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
@@ -114,6 +114,15 @@ public class MinHashFilter extends TokenFilter {
*/
public MinHashFilter(TokenStream input, int hashCount, int bucketCount, int hashSetSize, boolean withRotation) {
super(input);
+ if (hashCount <= 0) {
+ throw new IllegalArgumentException("hashCount must be greater than zero");
+ }
+ if (bucketCount <= 0) {
+ throw new IllegalArgumentException("bucketCount must be greater than zero");
+ }
+ if (hashSetSize <= 0) {
+ throw new IllegalArgumentException("hashSetSize must be greater than zero");
+ }
this.hashCount = hashCount;
this.bucketCount = bucketCount;
this.hashSetSize = hashSetSize;