diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 3590304bd90..0073182dc80 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -311,6 +311,8 @@ Other Changes * SOLR-13423: Upgrade RRD4j to version 3.5. (ab) +* SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined (Kevin Risden) + ================== 8.0.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrSchema.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrSchema.java index 5b0a74f11b6..b60844217e2 100644 --- a/solr/core/src/java/org/apache/solr/handler/sql/SolrSchema.java +++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrSchema.java @@ -18,7 +18,6 @@ package org.apache.solr.handler.sql; import java.io.IOException; import java.util.Collections; -import java.util.EnumSet; import java.util.Map; import java.util.Optional; import java.util.Properties; @@ -39,7 +38,6 @@ import org.apache.solr.client.solrj.response.LukeResponse; import org.apache.solr.common.cloud.Aliases; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.luke.FieldFlag; import com.google.common.collect.ImmutableMap; @@ -98,14 +96,20 @@ class SolrSchema extends AbstractSchema { // because we're creating a proto-type, not a type; before being used, the // proto-type will be copied into a real type factory. final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); - final RelDataTypeFactory.FieldInfoBuilder fieldInfo = typeFactory.builder(); + final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder(); Map luceneFieldInfoMap = getFieldInfo(collection); for(Map.Entry entry : luceneFieldInfoMap.entrySet()) { LukeResponse.FieldInfo luceneFieldInfo = entry.getValue(); + String luceneFieldType = luceneFieldInfo.getType(); + // SOLR-13414: Luke can return a field definition with no type in rare situations + if(luceneFieldType == null) { + continue; + } + RelDataType type; - switch (luceneFieldInfo.getType()) { + switch (luceneFieldType) { case "string": type = typeFactory.createJavaType(String.class); break; @@ -129,8 +133,8 @@ class SolrSchema extends AbstractSchema { type = typeFactory.createJavaType(String.class); } - EnumSet flags = luceneFieldInfo.parseFlags(luceneFieldInfo.getSchema()); /* + EnumSet flags = luceneFieldInfo.parseFlags(luceneFieldInfo.getSchema()); if(flags != null && flags.contains(FieldFlag.MULTI_VALUED)) { type = typeFactory.createArrayType(type, -1); }