You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2015/11/07 11:06:34 UTC

svn commit: r1713098 - in /lucene/dev/trunk/lucene: analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java core/src/java/org/apache/lucene/util/AttributeSource.java

Author: uschindler
Date: Sat Nov  7 10:06:34 2015
New Revision: 1713098

URL: http://svn.apache.org/viewvc?rev=1713098&view=rev
Log:
LUCENE-6879: Add missing null checks for parameters

Modified:
    lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java

Modified: lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java?rev=1713098&r1=1713097&r2=1713098&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java (original)
+++ lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharTokenizer.java Sat Nov  7 10:06:34 2015
@@ -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 exte
    * </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) {
       @Override
       protected boolean isTokenChar(int c) {

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java?rev=1713098&r1=1713097&r2=1713098&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java Sat Nov  7 10:06:34 2015
@@ -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");
   }
   
   /**