Skip to content

Commit

Permalink
removed custom exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Oct 20, 2018
1 parent 5e14aaa commit 6150ab0
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ teardown:
- match: { acknowledged: true }

- do:
catch: /ingest_cycle_exception/
catch: /illegal_state_exception/
index:
index: test
type: test
id: 1
pipeline: "outer"
body: {}
- match: { error.root_cause.0.type: "exception" }
- match: { error.root_cause.0.reason: "java.lang.IllegalArgumentException: org.elasticsearch.ingest.IngestCycleException: Cycle detected for pipeline: inner" }
- match: { error.root_cause.0.reason: "java.lang.IllegalArgumentException: java.lang.IllegalStateException: Cycle detected for pipeline: inner" }
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ teardown:
}
- length: { docs: 1 }
- length: { docs.0.processor_results: 1 }
- match: { docs.0.processor_results.0.error.reason: "java.lang.IllegalArgumentException: org.elasticsearch.ingest.IngestCycleException: Cycle detected for pipeline: outer" }
- match: { docs.0.processor_results.0.error.reason: "java.lang.IllegalArgumentException: java.lang.IllegalStateException: Cycle detected for pipeline: outer" }
- match: { docs.0.processor_results.0.error.caused_by.caused_by.reason: "Cycle detected for pipeline: outer" }

---
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,11 @@ private static Object deepCopy(Object value) {
* for this document.
* @param pipeline Pipeline to execute
* @throws Exception On exception in pipeline execution
* @throws IngestCycleException If an cycle (infinite loops) are found between pipelines
*/
public IngestDocument executePipeline(Pipeline pipeline) throws Exception {
try {
if (this.executedPipelines.add(pipeline) == false) {
throw new IngestCycleException("Cycle detected for pipeline: " + pipeline.getId());
throw new IllegalStateException("Cycle detected for pipeline: " + pipeline.getId());
}
return pipeline.execute(this);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
IngestDocument ingestDocumentCopy = new IngestDocument(ingestDocument);
ingestDocumentCopy.executePipeline(pipelineProcessor.getPipeline());
} catch (ElasticsearchException elasticsearchException) {
if (elasticsearchException.getCause().getCause() instanceof IngestCycleException) {
if (elasticsearchException.getCause().getCause() instanceof IllegalStateException) {
throw elasticsearchException;
}
//else do nothing, let the tracking processors throw the exception while recording the path up to the failure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void testActualPipelineProcessorWithCycle() throws Exception {

ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> trackingProcessor.execute(ingestDocument));
assertThat(exception.getCause(), instanceOf(IllegalArgumentException.class));
assertThat(exception.getCause().getCause(), instanceOf(IngestCycleException.class));
assertThat(exception.getCause().getCause(), instanceOf(IllegalStateException.class));
assertThat(exception.getMessage(), containsString("Cycle detected for pipeline: pipeline1"));
}

Expand Down

0 comments on commit 6150ab0

Please sign in to comment.