Apache Lucene open-source search software
SOLR-8984: EnumField's error reporting to indicate the name of the field
Ishan Chattopadhyaya76363e50d9e3
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9badab25c30..b2bc5478fea 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -66,6 +66,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----------------------diff --git a/solr/core/src/java/org/apache/solr/schema/EnumField.java b/solr/core/src/java/org/apache/solr/schema/EnumField.javaindex 60e65d56f3c..a60cd807421 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();diff --git a/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java b/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.javaindex aa5a8a9cf51..4d70c0ea842 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 {@Testpublic 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();