diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b6e72327004..e6b0c275c11 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -148,6 +148,9 @@ Bug Fixes
work as intended for an alias spanning more than 1 collection.
(Thomas Egense, Shawn Heisey, Mark Miller)
+* SOLR-5418: Background merge after field removed from solr.xml causes error.
+ (Reported on user's list, Robert M's patch via Erick Erickson)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java b/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java
index 7673131faa2..088375d00ac 100644
--- a/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java
@@ -54,25 +54,23 @@ public class SchemaCodecFactory extends CodecFactory implements SolrCoreAware {
codec = new Lucene46Codec() {
@Override
public PostingsFormat getPostingsFormatForField(String field) {
- final SchemaField fieldOrNull = core.getLatestSchema().getFieldOrNull(field);
- if (fieldOrNull == null) {
- throw new IllegalArgumentException("no such field " + field);
- }
- String postingsFormatName = fieldOrNull.getType().getPostingsFormat();
- if (postingsFormatName != null) {
- return PostingsFormat.forName(postingsFormatName);
+ final SchemaField schemaField = core.getLatestSchema().getFieldOrNull(field);
+ if (schemaField != null) {
+ String postingsFormatName = schemaField.getType().getPostingsFormat();
+ if (postingsFormatName != null) {
+ return PostingsFormat.forName(postingsFormatName);
+ }
}
return super.getPostingsFormatForField(field);
}
@Override
public DocValuesFormat getDocValuesFormatForField(String field) {
- final SchemaField fieldOrNull = core.getLatestSchema().getFieldOrNull(field);
- if (fieldOrNull == null) {
- throw new IllegalArgumentException("no such field " + field);
- }
- String docValuesFormatName = fieldOrNull.getType().getDocValuesFormat();
- if (docValuesFormatName != null) {
- return DocValuesFormat.forName(docValuesFormatName);
+ final SchemaField schemaField = core.getLatestSchema().getFieldOrNull(field);
+ if (schemaField != null) {
+ String docValuesFormatName = schemaField.getType().getDocValuesFormat();
+ if (docValuesFormatName != null) {
+ return DocValuesFormat.forName(docValuesFormatName);
+ }
}
return super.getDocValuesFormatForField(field);
}
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal.xml
index 78a4eb711d3..26af3a7cf5b 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal.xml
@@ -29,7 +29,7 @@
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
-
+