diff --git a/src/main/java/org/elasticsearch/index/codec/CodecModule.java b/src/main/java/org/elasticsearch/index/codec/CodecModule.java index 83db5846e1e..58470c3f39c 100644 --- a/src/main/java/org/elasticsearch/index/codec/CodecModule.java +++ b/src/main/java/org/elasticsearch/index/codec/CodecModule.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Scopes; import org.elasticsearch.common.inject.assistedinject.FactoryProvider; import org.elasticsearch.common.inject.multibindings.MapBinder; +import org.elasticsearch.common.settings.NoClassSettingsException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.codec.postingsformat.PostingFormats; import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider; @@ -92,13 +93,17 @@ public class CodecModule extends AbstractModule { String name = entry.getKey(); Settings settings = entry.getValue(); - Class type = - settings.getAsClass("type", null, "org.elasticsearch.index.codec.postingsformat.", "PostingsFormatProvider"); - - if (type == null) { - // nothing found, see if its in bindings as a binding name + String sType = settings.get("type"); + if (sType == null || sType.trim().isEmpty()) { throw new ElasticSearchIllegalArgumentException("PostingsFormat Factory [" + name + "] must have a type associated with it"); } + + Class type; + try { + type = settings.getAsClass("type", null, "org.elasticsearch.index.codec.postingsformat.", "PostingsFormatProvider"); + } catch (NoClassSettingsException e) { + throw new ElasticSearchIllegalArgumentException("The specified type [" + sType + "] for postingsFormat Factory [" + name + "] can't be found"); + } postingFormatProviders.put(name, type); } diff --git a/src/main/java/org/elasticsearch/index/codec/postingsformat/PostingsFormatService.java b/src/main/java/org/elasticsearch/index/codec/postingsformat/PostingsFormatService.java index f4d470998eb..5d4610b17c9 100644 --- a/src/main/java/org/elasticsearch/index/codec/postingsformat/PostingsFormatService.java +++ b/src/main/java/org/elasticsearch/index/codec/postingsformat/PostingsFormatService.java @@ -84,7 +84,7 @@ public class PostingsFormatService extends AbstractIndexComponent { public PostingsFormatProvider get(String name) throws ElasticSearchIllegalArgumentException { PostingsFormatProvider provider = providers.get(name); - if (name == null) { + if (provider == null) { throw new ElasticSearchIllegalArgumentException("failed to find postings_format [" + name + "]"); } return provider; diff --git a/src/main/java/org/elasticsearch/indices/IndexCreationException.java b/src/main/java/org/elasticsearch/indices/IndexCreationException.java index 5d38abcfa0b..6fb8d86c925 100644 --- a/src/main/java/org/elasticsearch/indices/IndexCreationException.java +++ b/src/main/java/org/elasticsearch/indices/IndexCreationException.java @@ -19,12 +19,13 @@ package org.elasticsearch.indices; +import org.elasticsearch.ElasticSearchWrapperException; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexException; /** */ -public class IndexCreationException extends IndexException { +public class IndexCreationException extends IndexException implements ElasticSearchWrapperException { public IndexCreationException(Index index, Throwable cause) { super(index, "failed to create index", cause);