fix: no other processors should be executed after on_failure is called in a compound processor (#19545)

This commit is contained in:
Tal Levy 2016-07-21 14:27:04 -07:00 committed by GitHub
parent 9765b4a6ff
commit 19e7b1c737
3 changed files with 19 additions and 0 deletions

View File

@ -109,6 +109,7 @@ public class CompoundProcessor implements Processor {
throw compoundProcessorException;
} else {
executeOnFailure(ingestDocument, compoundProcessorException);
break;
}
}
}

View File

@ -193,4 +193,17 @@ public class CompoundProcessorTests extends ESTestCase {
assertThat(firstProcessor.getInvokedCounter(), equalTo(1));
assertThat(secondProcessor.getInvokedCounter(), equalTo(1));
}
public void testBreakOnFailure() throws Exception {
TestProcessor firstProcessor = new TestProcessor("id1", "first", ingestDocument -> {throw new RuntimeException("error1");});
TestProcessor secondProcessor = new TestProcessor("id2", "second", ingestDocument -> {throw new RuntimeException("error2");});
TestProcessor onFailureProcessor = new TestProcessor("id2", "on_failure", ingestDocument -> {});
CompoundProcessor pipeline = new CompoundProcessor(false, Arrays.asList(firstProcessor, secondProcessor),
Collections.singletonList(onFailureProcessor));
pipeline.execute(ingestDocument);
assertThat(firstProcessor.getInvokedCounter(), equalTo(1));
assertThat(secondProcessor.getInvokedCounter(), equalTo(0));
assertThat(onFailureProcessor.getInvokedCounter(), equalTo(1));
}
}

View File

@ -19,6 +19,11 @@
"target_field" : "date",
"formats" : ["yyyy"]
}
},
{
"uppercase" : {
"field": "field1"
}
}
],
"on_failure" : [