mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
[TEST] fix NPE when generating random query (#26023)
`ClusterSearchShardsResponseTests.testSerialization` randomly uses `IdsQueryBuilderTests` to generate an alias filter. `IdsQueryBuilderTests` shecks if the array of current types is length zero but it can also be null which causes a `NullPointerException`. This changes adds a null check to avoid the exception. Closes #26021
This commit is contained in:
parent
bb3d5b7426
commit
aafd7f90fd
@ -20,9 +20,9 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
|
||||
import org.apache.lucene.search.TermInSetQuery;
|
||||
import org.apache.lucene.search.MatchNoDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermInSetQuery;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.mapper.UidFieldMapper;
|
||||
@ -39,7 +39,7 @@ public class IdsQueryBuilderTests extends AbstractQueryTestCase<IdsQueryBuilder>
|
||||
@Override
|
||||
protected IdsQueryBuilder doCreateTestQueryBuilder() {
|
||||
String[] types;
|
||||
if (getCurrentTypes().length > 0 && randomBoolean()) {
|
||||
if (getCurrentTypes() != null && getCurrentTypes().length > 0 && randomBoolean()) {
|
||||
int numberOfTypes = randomIntBetween(1, getCurrentTypes().length);
|
||||
types = new String[numberOfTypes];
|
||||
for (int i = 0; i < numberOfTypes; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user