Apache Lucene open-source search software
Fix map size in CustomAnalyzer#paramsToMap. (#14770)
zhouhui247b96e7f3ff
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/custom/CustomAnalyzer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/custom/CustomAnalyzer.javaindex 2c8afef5f2b..71906c220ef 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/custom/CustomAnalyzer.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/custom/CustomAnalyzer.java@@ -606,7 +606,7 @@ public final class CustomAnalyzer extends Analyzer {throw new IllegalArgumentException("Key-value pairs expected, so the number of params must be even.");}- final Map<String, String> map = CollectionUtil.newHashMap(params.length);+ final Map<String, String> map = CollectionUtil.newHashMap(params.length / 2);for (int i = 0; i < params.length; i += 2) {Objects.requireNonNull(params[i], "Key of param may not be null.");map.put(params[i], params[i + 1]);