ElasticsearchException.guessRootCauses would return wrapper exception if inner exception was not an ElasticsearchException. Fixed to never return wrapper exceptions. At least following APIs change root_cause.0.type as a result: _update with bad script _index with bad pipeline Relates #50417
This commit is contained in:
parent
0444da944e
commit
125feecabc
|
@ -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":
|
||||
|
@ -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]" }
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -641,7 +641,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
}
|
||||
}
|
||||
}
|
||||
return new ElasticsearchException[]{new ElasticsearchException(t.getMessage(), t) {
|
||||
return new ElasticsearchException[]{new ElasticsearchException(ex.getMessage(), ex) {
|
||||
@Override
|
||||
protected String getExceptionName() {
|
||||
return getExceptionName(getCause());
|
||||
|
|
|
@ -163,6 +163,16 @@ public class ElasticsearchExceptionTests extends ESTestCase {
|
|||
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);
|
||||
|
@ -788,9 +798,7 @@ public class ElasticsearchExceptionTests extends ESTestCase {
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue