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

Prevent throwing JSONParseException when the response is empty. #2125

Merged
merged 1 commit into from Nov 29, 2022

Conversation

aribon-cs
Copy link
Contributor

I saw this issue when I wanted to check whether an index exists in the elastic.
Elastica uses HEAD requests to check whether the index exists or not, so the response body is empty.
This issue is handled inside the code by try-catch (getData function). But there were two reasons for this PR:
1- by this change, we can check if the response is empty, don't call the JSON parse function. So no exception will occur, and there isn't any need to catch it.
2- we use newrelic for distributed tracing and see many errors. ( newrelic agent collects all exceptions even though they are handled, and we want to keep this ability for better tracing )

Copy link
Owner

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup! I wonder why we didn't write it this way in the first place 🤔 I'll wait on CI to complete and then get it in.

@ruflin ruflin merged commit b6ec347 into ruflin:master Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants