Skip to content
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: prevent hanging by call backgroundResources.close() on stub.close() [ggj] #804

Merged
merged 23 commits into from Aug 2, 2021

Conversation

miraleung
Copy link
Contributor

Closes #792.

@miraleung miraleung requested a review from a team as a code owner July 30, 2021 20:28
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 30, 2021
@codecov
Copy link

codecov bot commented Jul 30, 2021

Codecov Report

Merging #804 (e959ac1) into dev/try-catch-list (552af72) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                  Coverage Diff                   @@
##           dev/try-catch-list     #804      +/-   ##
======================================================
+ Coverage               91.30%   91.32%   +0.02%     
======================================================
  Files                     140      140              
  Lines                   15012    15050      +38     
  Branches                 1086     1086              
======================================================
+ Hits                    13707    13745      +38     
  Misses                   1009     1009              
  Partials                  296      296              
Impacted Files Coverage Δ
...poser/common/AbstractServiceStubClassComposer.java 98.46% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 552af72...e959ac1. Read the comment docs.

Base automatically changed from dev/throw-cause to master July 30, 2021 22:13
Copy link
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit hesitant originally, but giving it a closer look, seems like this PR really does the right thing: close() methods call close() underneath (instead of shutdown(), which was the old behavior). I mean shutdown() must call shutdown() for child resources, close() must call close() for child resources (instead of shutdown()), and this PR brings the generated code to that correct state.

Please address one comment about exception wraping before mergin.

@@ -430,7 +430,11 @@ public class GrpcPublisherStub extends PublisherStub {

@Override
public final void close() {
shutdown();
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this (exception wrapping) exists solely because backgroundResources.close() is checked (throws Exception), but the EchoStub.close()is declared as non-checked, so we need do something like that for things to compile. Either way it will be a breaking behavioral change. To mitigate it, I think we can wrap only what we must (checked exceptions), but throw as is all the unchecked exceptions, so please consider generating somethign like this instead:

   try {
      backgroundResources.close();
    } catch (RungimeException e) {
      thrown e;
    } catch (Exception e) {
      throw new IllegalStateException("Failed to close resource", e);
    }
  }

This will let us to avoid unnecessary exception wrapping, making this change differ less from the previous behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@miraleung miraleung changed the title fix: prevent hanging by call backgroundResources.close() on stub.close() [ggj] fix: prevent hanging by calling backgroundResources.close() on stub.close() [ggj] Aug 2, 2021
@miraleung miraleung changed the title fix: prevent hanging by calling backgroundResources.close() on stub.close() [ggj] fix: prevent hanging by call backgroundResources.close() on stub.close() [ggj] Aug 2, 2021
@miraleung miraleung changed the base branch from master to dev/try-catch-list August 2, 2021 21:12
Base automatically changed from dev/try-catch-list to master August 2, 2021 21:53
@miraleung miraleung merged commit 428db97 into master Aug 2, 2021
@miraleung miraleung deleted the dev/stub-close branch August 2, 2021 22:24
suztomo pushed a commit that referenced this pull request Mar 21, 2023
[![Mend 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.cloud:google-cloud-core](https://togithub.com/googleapis/java-core) | `2.8.12` -> `2.8.13` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.13/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.13/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.13/compatibility-slim/2.8.12)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.13/confidence-slim/2.8.12)](https://docs.renovatebot.com/merge-confidence/) |
| [com.google.cloud:google-cloud-core-bom](https://togithub.com/googleapis/java-core) | `2.8.12` -> `2.8.13` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core-bom/2.8.13/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core-bom/2.8.13/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core-bom/2.8.13/compatibility-slim/2.8.12)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core-bom/2.8.13/confidence-slim/2.8.12)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-core</summary>

### [`v2.8.13`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#&#8203;2813-httpsgithubcomgoogleapisjava-corecomparev2812v2813-2022-09-20)

[Compare Source](https://togithub.com/googleapis/java-core/compare/v2.8.12...v2.8.13)

##### Dependencies

-   Update dependency io.grpc:grpc-bom to v1.49.1 ([#&#8203;919](https://togithub.com/googleapis/java-core/issues/919)) ([2d481ba](https://togithub.com/googleapis/java-core/commit/2d481ba500e247d8fee49abe30a9eb84bdcc8d07))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

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

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

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

---

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

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-shared-dependencies).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTguMSIsInVwZGF0ZWRJblZlciI6IjMyLjE5OC4xIn0=-->
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


## [3.0.4](https://togithub.com/googleapis/java-shared-dependencies/compare/v3.0.3...v3.0.4) (2022-10-03)


### Dependencies

* Update dependency cachetools to v5 ([#816](https://togithub.com/googleapis/java-shared-dependencies/issues/816)) ([bd2569c](https://togithub.com/googleapis/java-shared-dependencies/commit/bd2569c8c26e177a83cbcf8ed63fed1c3fce2c4b))
* Update dependency certifi to v2022.9.24 ([#818](https://togithub.com/googleapis/java-shared-dependencies/issues/818)) ([5406a0c](https://togithub.com/googleapis/java-shared-dependencies/commit/5406a0ca7e4e2b47f87a39c0fc696fbfd7a6a196))
* Update dependency charset-normalizer to v2.1.1 ([#822](https://togithub.com/googleapis/java-shared-dependencies/issues/822)) ([5c998e4](https://togithub.com/googleapis/java-shared-dependencies/commit/5c998e4d05d47882743cdb5a871a6af728b9d920))
* Update dependency click to v8.1.3 ([#823](https://togithub.com/googleapis/java-shared-dependencies/issues/823)) ([2ad211a](https://togithub.com/googleapis/java-shared-dependencies/commit/2ad211abb259b0fc225303f695a2f0399e19cd66))
* Update dependency com.google.protobuf:protobuf-bom to v3.21.7 ([#837](https://togithub.com/googleapis/java-shared-dependencies/issues/837)) ([d5472aa](https://togithub.com/googleapis/java-shared-dependencies/commit/d5472aa3a98c7a10737b6a9137dba8140087a31b))
* Update dependency gcp-releasetool to v1.8.8 ([#819](https://togithub.com/googleapis/java-shared-dependencies/issues/819)) ([bfef3b0](https://togithub.com/googleapis/java-shared-dependencies/commit/bfef3b0cf05bc200e707dfbf0330d672d824004c))
* Update dependency gcp-releasetool to v1.8.9 ([#846](https://togithub.com/googleapis/java-shared-dependencies/issues/846)) ([533c6a6](https://togithub.com/googleapis/java-shared-dependencies/commit/533c6a6382c2e933b2e87834b5b94913c1dc4943))
* Update dependency google-api-core to v2.10.1 ([#824](https://togithub.com/googleapis/java-shared-dependencies/issues/824)) ([1a5d233](https://togithub.com/googleapis/java-shared-dependencies/commit/1a5d233efa85f1dbd3aa272d2d305d24a35a7576))
* Update dependency google-auth to v2.12.0 ([#825](https://togithub.com/googleapis/java-shared-dependencies/issues/825)) ([cbca860](https://togithub.com/googleapis/java-shared-dependencies/commit/cbca860ae78c7ddf4541ed8b7c057710299162a8))
* Update dependency google-cloud-core to v2.3.2 ([#820](https://togithub.com/googleapis/java-shared-dependencies/issues/820)) ([65a1310](https://togithub.com/googleapis/java-shared-dependencies/commit/65a1310f50ce6914a67cb5e0e4d258f9f4466f11))
* Update dependency google-cloud-storage to v2.5.0 ([#826](https://togithub.com/googleapis/java-shared-dependencies/issues/826)) ([5fd7983](https://togithub.com/googleapis/java-shared-dependencies/commit/5fd7983489b971344e64010c7cfef0a2f60be667))
* Update dependency google-crc32c to v1.5.0 ([#827](https://togithub.com/googleapis/java-shared-dependencies/issues/827)) ([ee9e013](https://togithub.com/googleapis/java-shared-dependencies/commit/ee9e013106173cefbc10563d5d51dd906997c658))
* Update dependency google-resumable-media to v2.4.0 ([#838](https://togithub.com/googleapis/java-shared-dependencies/issues/838)) ([fb02810](https://togithub.com/googleapis/java-shared-dependencies/commit/fb02810c4a975fc75b26d680266ac48f85779a70))
* Update dependency googleapis-common-protos to v1.56.4 ([#821](https://togithub.com/googleapis/java-shared-dependencies/issues/821)) ([49d6423](https://togithub.com/googleapis/java-shared-dependencies/commit/49d64234d57d99c07689d0dd66697bb94d69e958))
* Update dependency importlib-metadata to v4.12.0 ([#832](https://togithub.com/googleapis/java-shared-dependencies/issues/832)) ([33ef522](https://togithub.com/googleapis/java-shared-dependencies/commit/33ef5228cb4fda9ef24e2b4396f970bc5ab67322))
* Update dependency importlib-metadata to v4.13.0 ([#843](https://togithub.com/googleapis/java-shared-dependencies/issues/843)) ([333b61b](https://togithub.com/googleapis/java-shared-dependencies/commit/333b61baf0f42d64699626bbc57315b3a826c3d3))
* Update dependency importlib-metadata to v5 ([#845](https://togithub.com/googleapis/java-shared-dependencies/issues/845)) ([7dc299d](https://togithub.com/googleapis/java-shared-dependencies/commit/7dc299da70133bb0fa9a363816ea804d540edc22))
* Update dependency io.grpc:grpc-bom to v1.49.1 ([#802](https://togithub.com/googleapis/java-shared-dependencies/issues/802)) ([a810f58](https://togithub.com/googleapis/java-shared-dependencies/commit/a810f587a5551e5f36a0b161bc350ebcb636acd5))
* Update dependency io.grpc:grpc-bom to v1.49.2 ([#842](https://togithub.com/googleapis/java-shared-dependencies/issues/842)) ([064a166](https://togithub.com/googleapis/java-shared-dependencies/commit/064a1666dd030c5f9fe35da7ebbda3dad2421427))
* Update dependency jeepney to v0.8.0 ([#833](https://togithub.com/googleapis/java-shared-dependencies/issues/833)) ([d1a5a67](https://togithub.com/googleapis/java-shared-dependencies/commit/d1a5a672089424d3ef9f85ae5d87b669484466e5))
* Update dependency jinja2 to v3.1.2 ([#834](https://togithub.com/googleapis/java-shared-dependencies/issues/834)) ([ad63e98](https://togithub.com/googleapis/java-shared-dependencies/commit/ad63e988d2407a62491a309160e1b87b4cc06d9a))
* Update dependency keyring to v23.9.3 ([#828](https://togithub.com/googleapis/java-shared-dependencies/issues/828)) ([8fed728](https://togithub.com/googleapis/java-shared-dependencies/commit/8fed728e6c84c8cade5bb24a827c558345149cff))
* Update dependency markupsafe to v2.1.1 ([#829](https://togithub.com/googleapis/java-shared-dependencies/issues/829)) ([6a93716](https://togithub.com/googleapis/java-shared-dependencies/commit/6a93716f6f161ced9a08840037bbfe7bfeee0814))
* Update dependency org.threeten:threetenbp to v1.6.2 ([#808](https://togithub.com/googleapis/java-shared-dependencies/issues/808)) ([f03792d](https://togithub.com/googleapis/java-shared-dependencies/commit/f03792d49370e0abbe6f90d37c513920759d6581))
* Update dependency protobuf to v3.20.2 ([#830](https://togithub.com/googleapis/java-shared-dependencies/issues/830)) ([544c20f](https://togithub.com/googleapis/java-shared-dependencies/commit/544c20f9b45fc42ba6b0071153c05034ea08ddc3))
* Update dependency protobuf to v3.20.3 ([#839](https://togithub.com/googleapis/java-shared-dependencies/issues/839)) ([69db6d7](https://togithub.com/googleapis/java-shared-dependencies/commit/69db6d7e56d4673a68e1f49a805635d054856326))
* Update dependency protobuf to v4 ([#817](https://togithub.com/googleapis/java-shared-dependencies/issues/817)) ([d2df74f](https://togithub.com/googleapis/java-shared-dependencies/commit/d2df74f6f456acbcccee7120b0ab164f73b8af93))
* Update dependency pyjwt to v2.5.0 ([#812](https://togithub.com/googleapis/java-shared-dependencies/issues/812)) ([8439533](https://togithub.com/googleapis/java-shared-dependencies/commit/843953365e464c72aa62df1a512a0ca6086a1c37))
* Update dependency requests to v2.28.1 ([#813](https://togithub.com/googleapis/java-shared-dependencies/issues/813)) ([de1d896](https://togithub.com/googleapis/java-shared-dependencies/commit/de1d896da6d7dcaedb520117d675290826d23505))
* Update dependency typing-extensions to v4.3.0 ([#814](https://togithub.com/googleapis/java-shared-dependencies/issues/814)) ([eb8b96b](https://togithub.com/googleapis/java-shared-dependencies/commit/eb8b96b916281aad8f330eb506a7d4be420c4263))
* Update dependency zipp to v3.8.1 ([#815](https://togithub.com/googleapis/java-shared-dependencies/issues/815)) ([74ee8f7](https://togithub.com/googleapis/java-shared-dependencies/commit/74ee8f75795091303236322e6c090a6a2b3f30e5))
* Update gax.version to v2.19.2 ([#847](https://togithub.com/googleapis/java-shared-dependencies/issues/847)) ([63228ac](https://togithub.com/googleapis/java-shared-dependencies/commit/63228ac05cfa27c6ecfee44eb91a8fabb94c5f59))
* Update google.common-protos.version to v2.9.3 ([#803](https://togithub.com/googleapis/java-shared-dependencies/issues/803)) ([cdf3fe6](https://togithub.com/googleapis/java-shared-dependencies/commit/cdf3fe6f7b7abbb9ef0c4a7cd1e4783dbbe0e238))
* Update google.common-protos.version to v2.9.5 ([#831](https://togithub.com/googleapis/java-shared-dependencies/issues/831)) ([62b5617](https://togithub.com/googleapis/java-shared-dependencies/commit/62b5617fa7960a1fdbad5743e44f14e2b6014b47))
* Update google.common-protos.version to v2.9.6 ([#844](https://togithub.com/googleapis/java-shared-dependencies/issues/844)) ([0cd42ae](https://togithub.com/googleapis/java-shared-dependencies/commit/0cd42aee75de5e3ddcde03165620aebae3ce2df0))
* Update google.core.version to v2.8.13 ([#804](https://togithub.com/googleapis/java-shared-dependencies/issues/804)) ([d1b585e](https://togithub.com/googleapis/java-shared-dependencies/commit/d1b585eb836fa55a97ca059426bce15cafcb2b5e))
* Update google.core.version to v2.8.14 ([#805](https://togithub.com/googleapis/java-shared-dependencies/issues/805)) ([3743485](https://togithub.com/googleapis/java-shared-dependencies/commit/37434855f0ec5bef09a8e8b0a062aa1df93da102))
* Update google.core.version to v2.8.15 ([#807](https://togithub.com/googleapis/java-shared-dependencies/issues/807)) ([614586e](https://togithub.com/googleapis/java-shared-dependencies/commit/614586ed92f203901c80ab5539f5c514bb5fe131))
* Update google.core.version to v2.8.16 ([#810](https://togithub.com/googleapis/java-shared-dependencies/issues/810)) ([6d04bef](https://togithub.com/googleapis/java-shared-dependencies/commit/6d04bef8689e87a7505ecb18e556b7d55a05d649))
* Update google.core.version to v2.8.17 ([#835](https://togithub.com/googleapis/java-shared-dependencies/issues/835)) ([5e84cc5](https://togithub.com/googleapis/java-shared-dependencies/commit/5e84cc533778443b798550fe9e3cb0888ad9b8ac))
* Update google.core.version to v2.8.18 ([#840](https://togithub.com/googleapis/java-shared-dependencies/issues/840)) ([203e8b4](https://togithub.com/googleapis/java-shared-dependencies/commit/203e8b4681186f863bc8d2f7e79c3c0102e592b4))
* Update google.core.version to v2.8.19 ([#841](https://togithub.com/googleapis/java-shared-dependencies/issues/841)) ([35bf0dc](https://togithub.com/googleapis/java-shared-dependencies/commit/35bf0dcb1b8e6143fb7750dc3e8eeeb6bfac9a3b))
* Update google.core.version to v2.8.20 ([#848](https://togithub.com/googleapis/java-shared-dependencies/issues/848)) ([047dc3f](https://togithub.com/googleapis/java-shared-dependencies/commit/047dc3f6f1b1a0c27079c8bc07046793c96f8dfc))
* Update iam.version to v1.6.1 ([#806](https://togithub.com/googleapis/java-shared-dependencies/issues/806)) ([b2fc57a](https://togithub.com/googleapis/java-shared-dependencies/commit/b2fc57a99d63554f456f185c136954c688300ab7))
* Update iam.version to v1.6.2 ([#849](https://togithub.com/googleapis/java-shared-dependencies/issues/849)) ([1251c42](https://togithub.com/googleapis/java-shared-dependencies/commit/1251c42fd0e9f31991236a1bfd2ff7010ab22e70))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
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
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stub.close() should call close() on background resources
2 participants