-
Notifications
You must be signed in to change notification settings - Fork 859
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
Fix for S3Client with httpClient as url-connection-client fails with EOFException when executing HeadObjectRequest for gzip encoded object #3346
Conversation
f72cee6
to
2ebc014
Compare
@@ -302,7 +302,10 @@ public HttpExecuteResponse call() throws IOException { | |||
int responseCode = getResponseCodeSafely(connection); | |||
boolean isErrorResponse = HttpStatusFamily.of(responseCode).isOneOf(CLIENT_ERROR, SERVER_ERROR); | |||
Optional<InputStream> responseContent = isErrorResponse ? tryGetErrorStream() : tryGetInputStream(); | |||
AbortableInputStream responseBody = responseContent.map(AbortableInputStream::create).orElse(null); | |||
|
|||
AbortableInputStream responseBody = responseHasNoContent() |
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.
Should we do this in tryGetErrorStream and tryGetInputStream (or their downstream methods)? It seems weird that we have responseContent being present even when there's technically no content.
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.
- Agree, thats because of https://github.com/JetBrains/jdk8u_jdk/blob/master/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java#L1858
- Thus it make sense in adding in tryGetInputStream
- However in case of
tryGetErrorStream
we get null Stream in case of errors for all type of method like 'GET' , 'HEAD' etc , so I think it not required fortryGetErrorStream
…EOFException when executing HeadObjectRequest for gzip encoded objec
2ebc014
to
97bd139
Compare
return responseHasNoContent() | ||
? Optional.empty() | ||
: getAndHandle100Bug(() -> invokeSafely(connection::getInputStream), true); |
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.
Is it possible that we might need to check for no-content in tryGetErrorStream?
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.
It might be possible, but will do some deep dive , also will need to add a test case for this . Since I am going on leave will close this PR for now and will raise a separate PR when back from leave , will keep this task is in fast track
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.
As per the code walk we donot need this check for erroStreams , details in #3363
Kudos, SonarCloud Quality Gate passed! |
Motivation and Context
Modifications
Similar to other http client where the responseBody is set to Null when the response doesnot have stream in its entity or in other words if http response doesnot have payload.
Refererence
Async Htttp client ==>Treat zero-byte responses from HTTP clients as not having content when it comes to creating an SDK HTTP full request. #2201
Sync Http Client code ==> ApacheHttpClient_sdk_code
Testing
Screenshots (if appropriate)
Types of changes
Checklist
License