Apache Lucene open-source search software
LUCENE-6879: Add missing null checks for parameters
Uwe Schindlerccc60d6a110b
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.javaindex 621bec92b61..dc55ddaeeb3 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java@@ -18,6 +18,7 @@ package org.apache.lucene.analysis.util;*/import java.io.IOException;+import java.util.Objects;import java.util.function.IntPredicate;import java.util.function.IntUnaryOperator;@@ -116,6 +117,8 @@ public abstract class CharTokenizer extends Tokenizer {* </pre>*/public static CharTokenizer fromTokenCharPredicate(AttributeFactory factory, final IntPredicate tokenCharPredicate, final IntUnaryOperator normalizer) {+ Objects.requireNonNull(tokenCharPredicate, "predicate must not be null.");+ Objects.requireNonNull(normalizer, "normalizer must not be null");return new CharTokenizer(factory) {@Overrideprotected boolean isTokenChar(int c) {diff --git a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.javaindex 2b1ce86fe63..b1a8e3f27fc 100644--- a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java+++ b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java@@ -24,6 +24,7 @@ import java.util.LinkedHashSet;import java.util.Map;import java.util.Map.Entry;import java.util.NoSuchElementException;+import java.util.Objects;import java.util.Set;import org.apache.lucene.analysis.TokenStream; // for javadocs@@ -80,9 +81,7 @@ public class AttributeSource {* An AttributeSource that uses the same attributes as the supplied one.*/public AttributeSource(AttributeSource input) {- if (input == null) {- throw new IllegalArgumentException("input AttributeSource must not be null");- }+ Objects.requireNonNull(input, "input AttributeSource must not be null");this.attributes = input.attributes;this.attributeImpls = input.attributeImpls;this.currentState = input.currentState;@@ -96,7 +95,7 @@ public class AttributeSource {this.attributes = new LinkedHashMap<>();this.attributeImpls = new LinkedHashMap<>();this.currentState = new State[1];- this.factory = factory;+ this.factory = Objects.requireNonNull(factory, "AttributeFactory must not be null");}/**