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 — Wrap GZIPInputStream with a ConsumingInputStream to drain on close by chingor13 · Pull Request #749 · googleapis/google-http-java-client

Conversation

@chingor13

@chingor13 chingor13 commented Jul 15, 2019

Copy link
Copy Markdown
Contributor

Fixes #367

Sorry, something went wrong.

Uh oh!

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

All reactions
@chingor13
Wrap GZIPInputStream with a ConsumingInputStream to drain on close
9a3a9b1
@chingor13
chingor13 requested a review from a team July 15, 2019 23:40
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 15, 2019
@chingor13
Remove unused import
f621038
elharo
elharo reviewed Jul 29, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java
return content;
}

static class ConsumingInputStream extends InputStream {

@elharo elharo Jul 29, 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.

An outer class would better separate unrelated code. This is complex enough to justify it.

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
public void close() throws IOException {
if (!closed && inputStream != null) {
try {
drainInputStream(this);

@elharo elharo Jul 29, 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.

Why is it important to drain the input stream and throw away the excess data, instead of simply closing the stream?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google-http-client/src/test/java/com/google/api/client/http/HttpResponseTest.java
try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(dataToCompress.length)) {
GZIPOutputStream zipStream = new GZIPOutputStream((byteStream));
zipStream.write(dataToCompress);
zipStream.close();

@elharo elharo Jul 29, 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.

We should probably also have a case where there's extra data on the stream after the gzipped content, since handling that is the purpose of this PR.

Sorry, something went wrong.

Uh oh!

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

All reactions
elharo
elharo reviewed Jul 29, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java
}
}

static void drainInputStream(final InputStream inputStream) throws IOException {

@elharo elharo Jul 29, 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 think this method can be private. Also you've reinvented ByteStreams.exhaust from Guava.

Sorry, something went wrong.

Uh oh!

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

All reactions
codyoss added a commit to codyoss/google-http-java-client that referenced this pull request Oct 14, 2019
@codyoss
feat: wrap GZIPInputStream for connection reuse
d5a0de6
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.

Checkpicked from: googleapis#749
Fixes: googleapis#367
codyoss added a commit to codyoss/google-http-java-client that referenced this pull request Oct 14, 2019
@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 mentioned this pull request Oct 14, 2019
feat: wrap GZIPInputStream for connection reuse #840
Merged
codyoss added a commit that referenced this pull request Oct 18, 2019
@codyoss
feat: wrap GZIPInputStream for connection reuse (#840)
087a428
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
@chingor13 chingor13 closed this Oct 22, 2019
@chingor13
chingor13 deleted the chunked-keepalive branch October 22, 2019 00:37
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this pull request Aug 11, 2022
@igorbernstein2
fix: timing of stale token refreshes on ComputeEngine (googleapis#749)
c813d55
* fix: timing of stale token refreshes on ComputeEngine

ComputeEngine metadata server has its own token caching mechanism that will return a cached token until the last 5 minutes of its expiration. This has a negative interaction with stale token refreshes because stale token refresh kicks in T-6mins until T-5mins. This will cause every stale refresh to return the same stale token.

This PR updates the timing for ComputeEngineCredentials to start a stale refresh at T-4mins and consider the token expired at T-3 mins. The implementation is a bit noisy because it includes a change OAuth2Credentials to make the thresholds configureable and now that we targeting java8, I migrated to using java8 time data types

* fmt

* fix test

* fix test again

* remove debug code

* comments
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this pull request Aug 11, 2022
@release-please
chore: release 1.2.0 (googleapis#747)
39cca92
🤖 I have created a release \*beep\* \*boop\*
---
## [1.2.0](https://www.github.com/googleapis/google-auth-library-java/compare/v1.1.0...v1.2.0) (2021-09-30)


### Features

* add support for Workforce Pools ([googleapis#729](https://www.github.com/googleapis/google-auth-library-java/issues/729)) ([5f3fed7](https://www.github.com/googleapis/google-auth-library-java/commit/5f3fed79e22f3c2d585c5b03c01791b0f8109929))


### Bug Fixes

* allow empty workforce_pool_user_project ([googleapis#752](https://www.github.com/googleapis/google-auth-library-java/issues/752)) ([e1cbce1](https://www.github.com/googleapis/google-auth-library-java/commit/e1cbce1a5cb269c6613bc6d40f06145bd45099c0))
* timing of stale token refreshes on ComputeEngine ([googleapis#749](https://www.github.com/googleapis/google-auth-library-java/issues/749)) ([c813d55](https://www.github.com/googleapis/google-auth-library-java/commit/c813d55a78053ecbec1a9640e6c9814da87319eb))
* workforce audience ([googleapis#741](https://www.github.com/googleapis/google-auth-library-java/issues/741)) ([a08cacc](https://www.github.com/googleapis/google-auth-library-java/commit/a08cacc7990b9058c8f1af3f9d8d816119562cc4))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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 left review comments
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.

3 participants

@chingor13 @elharo @googlebot
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.