-
Notifications
You must be signed in to change notification settings - Fork 191
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
add ResponseException#status
#756
add ResponseException#status
#756
Conversation
dbd2033
to
2ca1627
Compare
java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Outdated
Show resolved
Hide resolved
java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Show resolved
Hide resolved
2ca1627
to
028b9c8
Compare
java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Outdated
Show resolved
Hide resolved
java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good! Does need a test even if it's just to exercise the code to make sure it really works and we don't accidentally remove it.
java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Outdated
Show resolved
Hide resolved
Hopp Schwiiz!! |
* Status code returned by Elasticsearch. Shortcut for | ||
* {@code response().status()}. | ||
*/ | ||
public int status() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Should it be status
or getStatus
? What's the convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i took this 1:1 from OpenSearchException
, presuming that this was the accepted convention. happy to change it to getStatus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've left it at status
for now pending your feedback
028b9c8
to
917bc5c
Compare
ok, i've added a small test for it (though i skipped on testing the existing things as |
this allows accessing the HTTP status code of the response when an API returns a `ResponseException`. this was not possible through `getResponse` since `Response` itself is package-private and thus its members (even though they are marked as `public`) are not accessible to external consumers. solves #749 Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
917bc5c
to
bb1160e
Compare
the test failure is a false reject due to infrastructure issues:
can you re-trigger it? (i don't have the rights for that) |
Thanks for doing this @rursprung! |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-756-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 863518c372629b70e986eb4f2ae23cdfa482c07e
# Push it to GitHub
git push --set-upstream origin backport/backport-756-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x Then, create a pull request where the |
@rursprung can you please manually backport it to 2.x so we can ship it sooner than later? |
done. thanks! |
this allows accessing the HTTP status code of the response when an API returns a `ResponseException`. this was not possible through `getResponse` since `Response` itself is package-private and thus its members (even though they are marked as `public`) are not accessible to external consumers. solves #749 Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com> (cherry picked from commit 863518c)
this allows accessing the HTTP status code of the response when an API returns a
ResponseException
. this was not possible throughgetResponse
sinceResponse
itself is package-private and thus its members (even though they are marked aspublic
) are not accessible to external consumers.as there's no test coverage for
ResponseException
i haven't added any for the new API either, as it is a trivial API and it was unclear how adding test coverage for it would fit into the existing test coverage.solves #749
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.
unrelated fun fact: 756 (the PR ID) is the ISO country code for my country 😄🇨🇭