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/25 17:57:45 UTC

[lucene-solr] branch jira/solr-13414 created (now d9b51f6)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a change to branch jira/solr-13414
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


      at d9b51f6  SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined

This branch includes the following new commits:

     new d9b51f6  SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-solr] 01/01: SOLR-13414: SolrSchema - Avoid NPE if Luke returns field with no type defined

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch jira/solr-13414
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit d9b51f6c70ec3b33f5d9eb8961a9b79e89a9cf7c
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>
---
 .../src/java/org/apache/solr/handler/sql/SolrSchema.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

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);
       }