opensearch-project / opensearch-project/opensearch-java

[FEATURE] Include the root exception cause within the ExecutionException thrown by the OpenSearchAsyncClient

Open
#425 1 comment 0 reactions 1 assignee View on GitHub

@harshavamsi is already working on this.

Since Apr 7, 2023.

enhancement
Dominant language
Java
Stars
165
Forks
250
Avg merge
1d 18h
Merged PRs (30d)
26

Description

Is your feature request related to a problem?

The OpenSearchAsyncClient is used to perform a GetIndicesSettingsRequest below to retrieve the indices settings for a particular index.

CompletableFuture<GetIndicesSettingsResponse> getIndicesSettingsResponse = sdkJavaAsyncClient
            ._transport()
            .performRequestAsync(getIndicesSettingsRequest, GetIndicesSettingsRequest._ENDPOINT, TransportOptions.builder().build());

In the case that the requested index is not found, the exception thrown is the java.util.concurrent.ExecutionException, which includes an inner exception cause of type org.opensearch.client.opensearch._types.OpenSearchException. The OpenSearchException does not include an inner cause, however it does provide the message : Request failed: [index_not_found_exception] no such index [.opendistro-anomaly-detector-jobs].

The full logs can be seen here :

00:28:12.909 [opensearch[ad-extension][generic][T#4]] INFO  org.opensearch.ad.indices.AnomalyDetectionIndices - Exception e : class java.util.concurrent.ExecutionException
00:28:12.909 [opensearch[ad-extension][generic][T#4]] INFO  org.opensearch.ad.indices.AnomalyDetectionIndices - Exception e.getCause() : class org.opensearch.client.opensearch._types.OpenSearchException
00:28:12.909 [opensearch[ad-extension][generic][T#4]] INFO  org.opensearch.ad.indices.AnomalyDetectionIndices - Exception e.getCause().getMessage() :Request failed: [index_not_found_exception] no such index [.opendistro-anomaly-detector-jobs]
What solution would you like?

The OpenSearchException.getCause() should return the actual exception thrown, not just the exception message. In this case, the expected exception should be IndexNotFoundException.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.