-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap exceptions thrown by async transport implementations in IOException
Signed-off-by: Andrew Parmet <[email protected]>
- Loading branch information
1 parent
57dc5cf
commit a29a5d1
Showing
6 changed files
with
83 additions
and
13 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
20 changes: 20 additions & 0 deletions
20
.../src/test/java/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,20 @@ | ||
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); | ||
|
||
stacktraceElements.forEach(System.out::println); | ||
|
||
var someElementContainsCallerMethodName = | ||
stacktraceElements.stream().anyMatch(it -> it.contains("testFailureFromClientPreservesStacktraceOfCaller")); | ||
|
||
assertTrue(someElementContainsCallerMethodName); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...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,6 @@ | ||
package org.opensearch.client.opensearch.integTest.aws; | ||
|
||
import org.opensearch.client.opensearch.integTest.AbstractAsyncStracktraceIT; | ||
|
||
public class AwsSdk2AsyncStacktraceIT extends AbstractAsyncStracktraceIT implements AwsSdk2AsyncTransportSupport { | ||
} |
46 changes: 46 additions & 0 deletions
46
...est/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2AsyncTransportSupport.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,46 @@ | ||
package org.opensearch.client.opensearch.integTest.aws; | ||
|
||
import org.apache.hc.core5.http.HttpHost; | ||
import org.opensearch.client.opensearch.integTest.OpenSearchTransportSupport; | ||
import org.opensearch.client.transport.OpenSearchTransport; | ||
import org.opensearch.client.transport.aws.AwsSdk2Transport; | ||
import org.opensearch.client.transport.aws.AwsSdk2TransportOptions; | ||
import org.opensearch.common.settings.Settings; | ||
import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient; | ||
import software.amazon.awssdk.regions.Region; | ||
|
||
import java.io.IOException; | ||
|
||
interface AwsSdk2AsyncTransportSupport extends OpenSearchTransportSupport { | ||
@Override | ||
default OpenSearchTransport buildTransport(Settings settings, HttpHost[] hosts) throws IOException { | ||
return new AwsSdk2Transport( | ||
getAsyncHttpClient(), | ||
getTestClusterHost(), | ||
getTestClusterServiceName(), | ||
getTestClusterRegion(), | ||
getTransportOptions().build()); | ||
} | ||
|
||
private String getTestClusterHost() { | ||
return System.getProperty("tests.awsSdk2support.domainHost"); | ||
} | ||
|
||
private String getTestClusterServiceName() { | ||
return System.getProperty("tests.awsSdk2support.serviceName"); | ||
} | ||
|
||
private Region getTestClusterRegion() { | ||
String region = System.getProperty("tests.awsSdk2support.domainRegion"); | ||
return region != null ? Region.of(region) : Region.US_EAST_1; | ||
} | ||
|
||
private AwsSdk2TransportOptions.Builder getTransportOptions() { | ||
return AwsSdk2TransportOptions.builder(); | ||
} | ||
|
||
private SdkAsyncHttpClient getAsyncHttpClient() { | ||
return AwsCrtAsyncHttpClient.create(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...c/test/java/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,6 @@ | ||
package org.opensearch.client.opensearch.integTest.httpclient5; | ||
|
||
import org.opensearch.client.opensearch.integTest.AbstractAsyncStracktraceIT; | ||
|
||
public class AsyncStacktraceIT extends AbstractAsyncStracktraceIT implements HttpClient5TransportSupport { | ||
} |