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

Catch IOExceptions from response body InputStream #486

Merged
merged 7 commits into from
Jul 7, 2021

Conversation

jeffdgr8
Copy link
Contributor

Changes

Handle exception from resultAdapter.fromJson(reader) call.

References

Closes #483

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. Since this library has unit testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

Could be JsonIOException, which is a RuntimeException, so catching all Exceptions
@jeffdgr8 jeffdgr8 requested a review from a team as a code owner June 11, 2021 06:18
@Marcono1234
Copy link
Contributor

Marcono1234 commented Jun 13, 2021

Should the potential exceptions from these lines be wrapped as well?

errorAdapter.fromJsonResponse(response.statusCode, reader)

(For fromJsonResponse maybe it would be the responsibility of the implementors of that method instead to catch the exceptions, so this might be outside the scope of this pull request.)

Copy link
Contributor

@lbalmaceda lbalmaceda 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 opening this. Looks good, left two change requests.

Co-authored-by: Luciano Balmaceda <[email protected]>
@jeffdgr8
Copy link
Contributor Author

Should the potential exceptions from these lines be wrapped as well?

errorAdapter.fromJsonResponse(response.statusCode, reader)

(For fromJsonResponse maybe it would be the responsibility of the implementors of that method instead to catch the exceptions, so this might be outside the scope of this pull request.)

@lbalmaceda as @Marcono1234 points out, this same exception or an IOException could result if the response is not a 200 and a similar error occurs while reading the response stream. It might work best to wrap this entire code segment to catch all exceptions from these sources. Or additionally wrap the errorAdapter calls at the bottom with a similar try/catch.

@lbalmaceda
Copy link
Contributor

@jeffdgr8 Please let me know whether you will be progressing this PR or if we should pick it up from our side - thanks.

@jeffdgr8
Copy link
Contributor Author

jeffdgr8 commented Jul 6, 2021

@lbalmaceda yes, sorry, had a busy last week. I'll take a look at this this evening.

@jeffdgr8
Copy link
Contributor Author

jeffdgr8 commented Jul 6, 2021

Should the potential exceptions from these lines be wrapped as well?

errorAdapter.fromJsonResponse(response.statusCode, reader)

(For fromJsonResponse maybe it would be the responsibility of the implementors of that method instead to catch the exceptions, so this might be outside the scope of this pull request.)

@lbalmaceda as @Marcono1234 points out, this same exception or an IOException could result if the response is not a 200 and a similar error occurs while reading the response stream. It might work best to wrap this entire code segment to catch all exceptions from these sources. Or additionally wrap the errorAdapter calls at the bottom with a similar try/catch.

Fixed 5c035ef

Copy link
Contributor

@lbalmaceda lbalmaceda 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 this!

@lbalmaceda lbalmaceda added this to the v2-Next milestone Jul 7, 2021
@lbalmaceda lbalmaceda merged commit a614bad into auth0:main Jul 7, 2021
@jeffdgr8 jeffdgr8 deleted the reponse-body-timeout branch July 7, 2021 17:20
@lbalmaceda lbalmaceda modified the milestones: v2-Next, 2.4.0 Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JsonIOException crash caused by SocketTimeoutException
3 participants