Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: do not double-wrap OpenSearchException. #323

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

dblock
Copy link
Member

@dblock dblock commented Jan 11, 2023

Signed-off-by: dblock dblock@amazon.com

Description

Before:

org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [http_exception] server returned 400
    at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse (AwsSdk2Transport.java:542)
    at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync (AwsSdk2Transport.java:442)
    at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest (AwsSdk2Transport.java:246)
    at org.opensearch.client.opensearch.indices.OpenSearchIndicesClient.create (OpenSearchIndicesClient.java:248)

After:

org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [resource_already_exists_exception] OpenSearch exception [type=resource_already_exists_exception, reason=index [movies/u0Qdo4UBHwS29ruw8Xao] already exists]
    at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse (AwsSdk2Transport.java:534)
    at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync (AwsSdk2Transport.java:442)
    at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest (AwsSdk2Transport.java:246)
    at org.opensearch.client.opensearch.indices.OpenSearchIndicesClient.create (OpenSearchIndicesClient.java:248)

Help me write a unit test for this? Is it worth it?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -456,6 +457,8 @@ private <ResponseT, ErrorT> ResponseT parseResponse(
ErrorT error = errorDeserializer.deserialize(parser, mapper);
throw new OpenSearchException((ErrorResponse) error);
}
} catch (OpenSearchException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to cover that with tests ... :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added integration test.

reta
reta previously approved these changes Jan 11, 2023
Signed-off-by: dblock <dblock@amazon.com>
reta
reta previously approved these changes Jan 12, 2023
@dblock
Copy link
Member Author

dblock commented Jan 14, 2023

@VachaShah care for a 2PR? thanks!

VachaShah
VachaShah previously approved these changes Jan 14, 2023
@dblock dblock dismissed stale reviews from VachaShah and reta via 9535254 January 15, 2023 14:10
@dblock dblock requested review from VachaShah and reta January 15, 2023 14:10
@dblock
Copy link
Member Author

dblock commented Jan 17, 2023

@VachaShah need one more pls

@reta reta merged commit 37d4800 into opensearch-project:main Jan 17, 2023
@dblock dblock deleted the do-not-wrap-exception branch January 17, 2023 19:53
@dblock dblock added the backport 2.x Backport to 2.x branch label Jan 17, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 17, 2023
Signed-off-by: dblock <dblock@amazon.com>

Signed-off-by: dblock <dblock@amazon.com>
(cherry picked from commit 37d4800)
dblock added a commit that referenced this pull request Jan 17, 2023
Signed-off-by: dblock <dblock@amazon.com>

(cherry picked from commit 37d4800)
reta pushed a commit that referenced this pull request Jan 23, 2023
Signed-off-by: dblock <dblock@amazon.com>

(cherry picked from commit 37d4800)

Co-authored-by: Daniel (dB.) Doubrovkine <dblock@amazon.com>
@BrendonFaleiro BrendonFaleiro mentioned this pull request Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants