-
Notifications
You must be signed in to change notification settings - Fork 332
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
Check that we have downloaded the file successfully #4627
Conversation
When we are downloading files we should check that the http call was successful instead of assuming that because no exception was thrown that the http status was successful. In the case were we get a 408, we don't throw an exception. This results in a InputStream of null to be returned. When reading from a InputStream of null, it infinitely returns a list of null bytes. In our use case we end up writing null to a temporary file until we run out of disk space We can also make this change in the `HttpSender` and throw when we get a none successful http code
rewrite-core/src/test/java/org/openrewrite/remote/RemoteArchiveTest.java
Outdated
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.
I agree with Tim's feedback about asserting exceptions but otherwise this looks good
I'm also going to update the test to each have their own cache, because at the moment only the 1st test running the expect logic while the others are falling back to the cache and aren't testing the expected logic |
@@ -93,7 +93,11 @@ public InputStream getInputStream(ExecutionContext ctx) { | |||
Path localArchive = cache.compute(uri, () -> { | |||
//noinspection resource | |||
HttpSender.Response response = httpSender.send(httpSender.get(uri.toString()).build()); | |||
return response.getBody(); | |||
if (response.isSuccessful()) { |
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.
question to team:
should we be doing some type of retry here to improve reliability with transient errors like network glitch or delays?
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.
If want to implement retires, I think we might want to move this change to the HttpSender
, I suspect other endpoints could benefit from it
When we are downloading files we should check that the http call was successful instead of assuming that because no exception was thrown that the http status was successful. In the case were we get a 408, we don't throw an exception. This results in a InputStream of null to be returned. When reading from a InputStream of null, it infinitely returns a list of null bytes. In our use case we end up writing null to a temporary file until we run out of disk space
We can also make this change in the
HttpSender
and throw when we get a none successful http code