You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2019/04/26 14:00:03 UTC
[lucene-solr] branch branch_8x updated: SOLR-13414: SolrSchema -
Avoid NPE if Luke returns field with no type defined
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 0e7e470 SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined
0e7e470 is described below
commit 0e7e470ada7f779330fe8c7da110b39a5626fa3b
Author: Kevin Risden <kr...@apache.org>
AuthorDate: Thu Apr 25 13:56:15 2019 -0400
SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined
Signed-off-by: Kevin Risden <kr...@apache.org>
---
solr/CHANGES.txt | 2 ++
.../src/java/org/apache/solr/handler/sql/SolrSchema.java | 14 +++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 15649bd..3a9495e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -286,6 +286,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 5b0a74f..b608442 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<String, LukeResponse.FieldInfo> luceneFieldInfoMap = getFieldInfo(collection);
for(Map.Entry<String, LukeResponse.FieldInfo> 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<FieldFlag> flags = luceneFieldInfo.parseFlags(luceneFieldInfo.getSchema());
/*
+ EnumSet<FieldFlag> flags = luceneFieldInfo.parseFlags(luceneFieldInfo.getSchema());
if(flags != null && flags.contains(FieldFlag.MULTI_VALUED)) {
type = typeFactory.createArrayType(type, -1);
}