From b16d7117a3b3ab1307ecebd11b2c983b50c265d9 Mon Sep 17 00:00:00 2001 From: Zhang Chao <80152403@qq.com> Date: Thu, 15 Feb 2024 23:20:53 +0800 Subject: [PATCH] Fix NPE for TestRandomChains.testRandomChainsWithLargeStrings (#13104) --- .../java/org/apache/lucene/analysis/shingle/ShingleFilter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java index 1eb4357eef1..e9520815dad 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java @@ -19,6 +19,7 @@ package org.apache.lucene.analysis.shingle; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; +import java.util.Objects; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; @@ -175,7 +176,7 @@ public final class ShingleFilter extends TokenFilter { * @param tokenType token tokenType */ public void setTokenType(String tokenType) { - this.tokenType = tokenType; + this.tokenType = Objects.requireNonNull(tokenType, "tokenType"); } /**