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

Add extra logging for the failure case of the HTTP request. #1736

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fozzie15
Copy link
Contributor

Add extra logging to catch issue where bad responses return HTTP instead of valid JSON.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 42.30%. Comparing base (d7db191) to head (bc6dc08).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1736      +/-   ##
============================================
- Coverage     42.32%   42.30%   -0.02%     
+ Complexity     3182     3179       -3     
============================================
  Files           794      794              
  Lines         46244    46248       +4     
  Branches       4951     4951              
============================================
- Hits          19572    19566       -6     
- Misses        25074    25082       +8     
- Partials       1598     1600       +2     
Components Coverage Δ
spanner-templates 63.67% <ø> (-0.03%) ⬇️
spanner-import-export 64.38% <ø> (-0.07%) ⬇️
spanner-live-forward-migration 74.97% <ø> (ø)
spanner-live-reverse-replication 51.84% <ø> (ø)
spanner-bulk-migration 82.79% <ø> (ø)
Files Coverage Δ
...leport/v2/elasticsearch/utils/ElasticsearchIO.java 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

@fozzie15 fozzie15 force-pushed the elasticsearch-logging branch from 1bf39d0 to 5f3198b Compare July 19, 2024 15:03
@fozzie15 fozzie15 force-pushed the elasticsearch-logging branch from 5f3198b to bc6dc08 Compare July 19, 2024 19:43
@fozzie15 fozzie15 marked this pull request as ready for review July 22, 2024 17:02
} catch (IOException jsonException) {
throw new IOException(
"The response is not a valid JSON: "
+ IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8));
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a unit test for this? Make sure an exception is thrown with the HTTP response body in the message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants