lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From is...@apache.org
Subject lucene-solr:branch_7x: SOLR-8984: EnumField's error reporting to indicate the name of the field
Date Fri, 14 Jul 2017 12:56:03 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 296808069 -> 1221fef87


SOLR-8984: EnumField's error reporting to indicate the name of the field


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1221fef8
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1221fef8
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1221fef8

Branch: refs/heads/branch_7x
Commit: 1221fef87d5aec82a739d9bc4c9fae7d93b5e340
Parents: 2968080
Author: Ishan Chattopadhyaya <ishan@apache.org>
Authored: Fri Jul 14 18:25:00 2017 +0530
Committer: Ishan Chattopadhyaya <ishan@apache.org>
Committed: Fri Jul 14 18:25:53 2017 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                             | 3 +++
 solr/core/src/java/org/apache/solr/schema/EnumField.java     | 7 +++++--
 solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java | 6 +++---
 3 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1221fef8/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5df0c6d..d0661d2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -49,6 +49,9 @@ Bug Fixes
 
 * SOLR-10668: fix NPE at sort=childfield(..) .. on absent values (Mikhail Khludnev)
 
+* SOLR-8984: EnumField's error reporting to now indicate the field name in failure log (Lanny
Ripple,
+  Ann Addicks via Ishan Chattopadhyaya)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1221fef8/solr/core/src/java/org/apache/solr/schema/EnumField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/EnumField.java b/solr/core/src/java/org/apache/solr/schema/EnumField.java
index 60e65d5..a60cd80 100644
--- a/solr/core/src/java/org/apache/solr/schema/EnumField.java
+++ b/solr/core/src/java/org/apache/solr/schema/EnumField.java
@@ -386,8 +386,11 @@ public class EnumField extends PrimitiveFieldType {
       return null;
     }
     final Integer intValue = stringValueToIntValue(value.toString());
-    if (intValue == null || intValue.equals(DEFAULT_VALUE))
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown value for enum
field: " + value.toString());
+    if (intValue == null || intValue.equals(DEFAULT_VALUE)) {
+      String exceptionMessage = String.format(Locale.ENGLISH, "Unknown value for enum field:
%s, value: %s",
+          field.getName(), value.toString());
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,  exceptionMessage);
+    }
 
     final LegacyFieldType newType = new LegacyFieldType();
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1221fef8/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java b/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
index aa5a8a9..4d70c0e 100644
--- a/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
@@ -152,9 +152,9 @@ public class EnumFieldTest extends SolrTestCaseJ4 {
   @Test
   public void testBogusEnumIndexing() throws Exception {
 
-    ignoreException("Unknown value for enum field: blabla");
-    ignoreException("Unknown value for enum field: 10");
-    ignoreException("Unknown value for enum field: -4");
+    ignoreException("Unknown value for enum field: " + FIELD_NAME + ", value: blabla");
+    ignoreException("Unknown value for enum field: " + FIELD_NAME + ", value: 10");
+    ignoreException("Unknown value for enum field: " + FIELD_NAME + ", value: -4");
 
     clearIndex();
 


Mime
View raw message