Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guess root cause support unwrap (#50525) #50742

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ teardown:
id: 1
pipeline: "outer"
body: {}
- match: { error.root_cause.0.type: "ingest_processor_exception" }
- match: { error.root_cause.0.reason: "java.lang.IllegalStateException: Cycle detected for pipeline: outer" }
- match: { error.root_cause.0.type: "illegal_state_exception" }
- match: { error.root_cause.0.reason: "Cycle detected for pipeline: outer" }

---
"Test Pipeline Processor with templating":
Expand Down Expand Up @@ -200,5 +200,5 @@ teardown:
{
"org": "legal"
}
- match: { error.root_cause.0.type: "ingest_processor_exception" }
- match: { error.root_cause.0.reason: "java.lang.IllegalStateException: Pipeline processor configured for non-existent pipeline [legal-department]" }
- match: { error.root_cause.0.type: "illegal_state_exception" }
- match: { error.root_cause.0.reason: "Pipeline processor configured for non-existent pipeline [legal-department]" }
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
source: "ctx._source.ctx = ctx"
params: { bar: 'xxx' }

- match: { error.root_cause.0.type: "remote_transport_exception" }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.type: "illegal_argument_exception" }
- match: { error.reason: "Iterable object is self-referencing itself" }
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public static ElasticsearchException[] guessRootCauses(Throwable t) {
}
}
}
return new ElasticsearchException[]{new ElasticsearchException(t.getMessage(), t) {
return new ElasticsearchException[]{new ElasticsearchException(ex.getMessage(), ex) {
@Override
protected String getExceptionName() {
return getExceptionName(getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ public void testGuessRootCause() {
assertEquals("illegal_argument_exception", foobars[0].getExceptionName());
}

{
final ElasticsearchException[] foobars = ElasticsearchException.guessRootCauses(
new RemoteTransportException("abc", new IllegalArgumentException("foobar")));
assertEquals(foobars.length, 1);
assertThat(foobars[0], instanceOf(ElasticsearchException.class));
assertEquals("foobar", foobars[0].getMessage());
assertEquals(IllegalArgumentException.class, foobars[0].getCause().getClass());
assertEquals("illegal_argument_exception", foobars[0].getExceptionName());
}

{
XContentParseException inner = new XContentParseException(null, "inner");
XContentParseException outer = new XContentParseException(null, "outer", inner);
Expand Down Expand Up @@ -788,9 +798,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException {
failure = new BroadcastShardOperationFailedException(new ShardId("_index", "_uuid", 5), "F", failureCause);

expected = new ElasticsearchException("Elasticsearch exception [type=file_already_exists_exception, reason=File exists]");
// strangely, the wrapped exception appears as the root cause...
suppressed = new ElasticsearchException("Elasticsearch exception [type=broadcast_shard_operation_failed_exception, " +
"reason=F]");
suppressed = new ElasticsearchException("Elasticsearch exception [type=file_already_exists_exception, reason=File exists]");
expected.addSuppressed(suppressed);
break;

Expand Down