Cleanly close the read channel in the GoogleHadoopFSInputStream so that read to EOF does not happen on calling close() unnecessarily - #1741
Conversation
…hat read to EOF does not happen on calling close() unnecessarily
There was a problem hiding this comment.
Code Review
This pull request updates GoogleCloudStorageReadChannel to track and disconnect the active HTTP media response before closing the content channel, preventing Apache HTTP's ContentLengthInputStream from draining the remaining response body. It also introduces corresponding unit tests. The review feedback suggests removing the event bus exception logging from disconnectHttpResponse to avoid false positives, restoring the original try-catch block in openStream to properly suppress cleanup exceptions, and adding a @Nullable annotation to the overridden test method to match the base class signature.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…on stale reference
|
|
Also need googleapis/google-http-java-client#1303 fixed before this is merged. The disconnect is broken at google http library level, it forces drain before disconnect. |
|
Refer to comment. |



Fixes #1729.
Calling close() on
GoogleHadoopFSInputStreamcaused the whole stream to get drained, with AUTO/SEQUENTIAL fadvise (default) the stream is opened to the EOF, and hence whole file has to be read once opened even when calling close().This PR cleanly closes the connection before Apache HTTP library tries to drain the bytes, so that only necessary bytes are read rest is dropped by closure of underlying HTTP response.