-
Notifications
You must be signed in to change notification settings - Fork 191
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) * wrap exceptions thrown by async transport implementations in IOException Signed-off-by: Andrew Parmet <[email protected]> * license headers Signed-off-by: Andrew Parmet <[email protected]> * changelog Signed-off-by: Andrew Parmet <[email protected]> * tolerate null causes Signed-off-by: Andrew Parmet <[email protected]> * fix tests Signed-off-by: Andrew Parmet <[email protected]> * remove print Signed-off-by: Andrew Parmet <[email protected]> * one more license header Signed-off-by: Andrew Parmet <[email protected]> * fix last non-aws test Signed-off-by: Andrew Parmet <[email protected]> * use multicatch to restrict caught exceptions Signed-off-by: Andrew Parmet <[email protected]> * Replicate the RestClient exception wrapping for async invocation flow Signed-off-by: Andriy Redko <[email protected]> * replicate hc5 exception extraction strategy in aws transport Signed-off-by: Andrew Parmet <[email protected]> * move other tests Signed-off-by: Andrew Parmet <[email protected]> * lint Signed-off-by: Andrew Parmet <[email protected]> * delete aws test for now; add support for OpenSearchClientException Signed-off-by: Andrew Parmet <[email protected]> * reintroduce an aws test, sadly, not extending the abstract case Signed-off-by: Andrew Parmet <[email protected]> * java 8 Signed-off-by: Andrew Parmet <[email protected]> * replicate ISE Signed-off-by: Andrew Parmet <[email protected]> * poke Signed-off-by: Andrew Parmet <[email protected]> * handle some netty-specific channel exceptions Signed-off-by: Andrew Parmet <[email protected]> * poke Signed-off-by: Andrew Parmet <[email protected]> * nevermind netty Signed-off-by: Andrew Parmet <[email protected]> * io before rt Signed-off-by: Andrew Parmet <[email protected]> * no hc5 Signed-off-by: Andrew Parmet <[email protected]> --------- Signed-off-by: Andrew Parmet <[email protected]> Signed-off-by: Andriy Redko <[email protected]> Co-authored-by: Andriy Redko <[email protected]>
- Loading branch information
1 parent
31905de
commit db50b7d
Showing
6 changed files
with
225 additions
and
19 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 {} |