-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recreate or wrap exceptions thrown by async transport implementations…
… to preserve caller stack traces (#656) (#1006) * wrap exceptions thrown by async transport implementations in IOException * license headers * changelog * tolerate null causes * fix tests * remove print * one more license header * fix last non-aws test * use multicatch to restrict caught exceptions * Replicate the RestClient exception wrapping for async invocation flow * replicate hc5 exception extraction strategy in aws transport * move other tests * lint * delete aws test for now; add support for OpenSearchClientException * reintroduce an aws test, sadly, not extending the abstract case * java 8 * replicate ISE * poke * handle some netty-specific channel exceptions * poke * nevermind netty * io before rt * no hc5 --------- (cherry picked from commit db50b7d) Signed-off-by: Andrew Parmet <andrew@parmet.com> Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Andriy Redko <andriy.redko@aiven.io>
- Loading branch information
1 parent
c5a84c1
commit 4f01790
Showing
6 changed files
with
224 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...rc/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2AsyncStacktraceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch.integTest.aws; | ||
|
||
import static org.junit.Assert.assertThrows; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.List; | ||
import org.apache.logging.log4j.core.util.Throwables; | ||
import org.junit.Test; | ||
import org.opensearch.client.opensearch.OpenSearchClient; | ||
|
||
// It would be nice to extend AbstractAsyncStracktraceIT. | ||
public class AwsSdk2AsyncStacktraceIT extends AwsSdk2TransportTestCase { | ||
@Test | ||
public void testFailureFromClientPreservesStacktraceOfCaller() throws Exception { | ||
final OpenSearchClient client = getClient(false, null, null); | ||
Exception thrown = assertThrows(Exception.class, () -> client.indices().get(g -> g.index("nonexisting-index"))); | ||
|
||
List<String> stacktraceElements = Throwables.toStringList(thrown); | ||
boolean someElementContainsCallerMethodName = stacktraceElements.stream() | ||
.anyMatch(it -> it.contains("testFailureFromClientPreservesStacktraceOfCaller")); | ||
|
||
assertTrue(someElementContainsCallerMethodName); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...rc/test/java11/org/opensearch/client/opensearch/integTest/AbstractAsyncStracktraceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch.integTest; | ||
|
||
import org.apache.logging.log4j.core.util.Throwables; | ||
import org.junit.Test; | ||
|
||
public abstract class AbstractAsyncStracktraceIT extends OpenSearchJavaClientTestCase { | ||
@Test | ||
public void testFailureFromClientPreservesStacktraceOfCaller() throws Exception { | ||
var thrown = assertThrows(Exception.class, () -> javaClient().indices().get(g -> g.index("nonexisting-index"))); | ||
|
||
var stacktraceElements = Throwables.toStringList(thrown); | ||
var someElementContainsCallerMethodName = stacktraceElements.stream() | ||
.anyMatch(it -> it.contains("testFailureFromClientPreservesStacktraceOfCaller")); | ||
|
||
assertTrue(someElementContainsCallerMethodName); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...test/java11/org/opensearch/client/opensearch/integTest/httpclient5/AsyncStacktraceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch.integTest.httpclient5; | ||
|
||
import org.opensearch.client.opensearch.integTest.AbstractAsyncStracktraceIT; | ||
|
||
public class AsyncStacktraceIT extends AbstractAsyncStracktraceIT implements HttpClient5TransportSupport {} |