From 313edcc8784501feeb896bcbe6a65b196ce87258 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Thu, 4 Mar 2021 13:33:54 -0500 Subject: [PATCH] Make SolrInputField name optional Prevents other bugs by failing fast --- .../processor/AddSchemaFieldsUpdateProcessorFactoryTest.java | 2 +- .../src/java/org/apache/solr/common/SolrInputField.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java index a49e9fe9b772..51e218d3d802 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java @@ -71,7 +71,7 @@ public void testEmptyValue() { SolrInputDocument finalDoc = doc; expectThrows(AssertionError.class, () -> processAdd("add-fields-no-run-processor", finalDoc)); - expectThrows(AssertionError.class, () -> processAdd("add-fields-no-run-processor", new SolrInputDocument(null , null))); + expectThrows(NullPointerException.class, () -> processAdd("add-fields-no-run-processor", new SolrInputDocument(null , null))); } public void testSingleField() throws Exception { diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java index f823ade770bc..3a54c923e515 100644 --- a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java +++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.Objects; /** * @@ -32,7 +33,7 @@ public class SolrInputField implements Iterable, Serializable public SolrInputField( String n ) { - this.name = n; + this.name = Objects.requireNonNull(n); } //--------------------------------------------------------------- @@ -161,7 +162,7 @@ public String getName() { } public void setName(String name) { - this.name = name; + this.name = Objects.requireNonNull(name); } @Override