GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: wrap GZIPInputStream for connection reuse by codyoss · Pull Request #840 · googleapis/google-http-java-client

Conversation

@codyoss

@codyoss codyoss commented Oct 14, 2019

Copy link
Copy Markdown
Member

If a connection is closed and there are some bytes that have not
been read that connection can't be reused. Now GZIPInputStream
will have all of its bytes read on close automatically to promote
connection reuse.

Cherry-picked: #749
Fixes: #367

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chingor13 and others added 2 commits October 14, 2019 09:52
@chingor13 @codyoss
Wrap GZIPInputStream with a ConsumingInputStream to drain on close
abf01a5
@codyoss
feat: wrap GZIPInputStream for connection reuse
756987a
If a connection is closed and there are some bytes that have not
been read that connection can't be reused. Now GZIPInputStream
will have all of its bytes read on close automatically to promote
connection reuse.

Cherry-picked: googleapis#749
Fixes: googleapis#367
@codyoss
codyoss requested a review from a team October 14, 2019 18:33
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 14, 2019
@codyoss

codyoss commented Oct 14, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Noticed that #749 had not been updated in a while so I cherry picked and fixed the PR comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo reviewed Oct 14, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/ConsumingInputStream.java

/**
* This class in meant to wrap an {@link InputStream} so that all bytes in the steam are read and
* discarded on {@link InputStream#close()}. This ensures that the underlying connection has the

@elharo elharo Oct 14, 2019

Copy link
Copy Markdown
Contributor

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.

What if the stream never ends?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@codyoss codyoss Oct 14, 2019

Copy link
Copy Markdown
Member Author

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.

That is a very good question. I am not sure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/ConsumingInputStream.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/ConsumingInputStream.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/ConsumingInputStream.java
public void close() throws IOException {
if (!closed && inputStream != null) {
try {
ByteStreams.exhaust(this);

@elharo elharo Oct 14, 2019

Copy link
Copy Markdown
Contributor

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 wonder if we could have an infinite loop here. See internal discussion.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@codyoss
address comments from PR
787976a
@codyoss

codyoss commented Oct 17, 2019

Copy link
Copy Markdown
Member Author

@elharo I fixed all of the comments. Do you still have reservations around a possible infinite stream? If so, any thought on how we should move forward with this?(Maybe we just don't if we think the infinite stream is too big of a risk as this feature requires exhausting all of the extra bytes for it to work.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo approved these changes Oct 18, 2019
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

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.

given how this is used and that it's non-public the infinite steam issue probably won't come up

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@codyoss
codyoss merged commit 087a428 into googleapis:master Oct 18, 2019
@codyoss
codyoss deleted the chuncked-keepalive branch October 18, 2019 17:36
This was referenced Mar 5, 2020
chunked encoding + GZIP prevents keep-alive #367
Closed
fix: Correctly handling chunked response streams with gzip #990
Merged
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this pull request Aug 11, 2022
@renovate-bot
chore(deps): update dependency com.google.appengine:appengine-api-1.0…
53f766a
…-sdk to v2.0.3 (googleapis#840)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.appengine:appengine-api-1.0-sdk](https://togithub.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.2` -> `2.0.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.3/compatibility-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.3/confidence-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>GoogleCloudPlatform/appengine-java-standard</summary>

### [`v2.0.3`](https://togithub.com/GoogleCloudPlatform/appengine-java-standard/releases/v2.0.3)

Release 2.0.3 from github open source code.

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/google-auth-library-java).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@elharo elharo elharo approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

chunked encoding + GZIP prevents keep-alive

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@codyoss @elharo @googlebot @chingor13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.