mirror of https://github.com/apache/lucene.git
SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined
Signed-off-by: Kevin Risden <krisden@apache.org>
This commit is contained in:
parent
ef79dd548d
commit
35aeb7f623
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue