Skip to content

Commit

Permalink
EnrichProcessorFactory should not throw NPE if missing metadata (#55977
Browse files Browse the repository at this point in the history
…) (#56798)

In some cases the Enrich processor factory may be called before it is
ready to create processors. While these calls are usually made in error,
the response from the Enrich processor is an NPE which is almost always
an unhelpful error when debugging an issue.
  • Loading branch information
jbaiera authored May 15, 2020
1 parent 6d269ab commit 0b1eb22
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ final class EnrichProcessorFactory implements Processor.Factory, Consumer<Cluste
public Processor create(Map<String, Processor.Factory> processorFactories, String tag, Map<String, Object> config) throws Exception {
String policyName = ConfigurationUtils.readStringProperty(TYPE, tag, config, "policy_name");
String policyAlias = EnrichPolicy.getBaseName(policyName);
if (metaData == null) {
throw new IllegalStateException("enrich processor factory has not yet been initialized with cluster state");
}
AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(policyAlias);
if (aliasOrIndex == null) {
throw new IllegalArgumentException("no enrich index exists for policy with name [" + policyName + "]");
Expand Down

0 comments on commit 0b1eb22

Please sign in to comment.