Skip to content

Commit

Permalink
Guess root cause support unwrap
Browse files Browse the repository at this point in the history
ElasticsearchException.guessRootCauses would return wrapper exception if
inner exception was not an ElasticsearchException. Fixed to never return
wrapper exceptions.

Relates elastic#50417
  • Loading branch information
henningandersen committed Dec 30, 2019
1 parent 66959be commit 60a6e4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 60a6e4d

Please sign in to comment.