Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

docs(samples): add try blocks to clean up resources in samples and sample tests #521

Merged
merged 27 commits into from
Jul 19, 2022

Conversation

aribray
Copy link
Contributor

@aribray aribray commented Jul 17, 2022

Change-Id: Ie68f4715646942d2e78189b3477cb9a5a31713b8

Adds try blocks to clean up resources such as threads in samples and sample tests.

Adds a helpful comment to code snippets that explains the need for either try-with-resources or close().

Note: close() needs to be called on the [Client] object to clean up resources such as threads. 
In the example below, try-with-resources is used, which automatically calls close().

Change-Id: Ie68f4715646942d2e78189b3477cb9a5a31713b8
@conventional-commit-lint-gcf
Copy link

conventional-commit-lint-gcf bot commented Jul 17, 2022

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: dialogflow Issues related to the googleapis/java-dialogflow-cx API. samples Issues that are directly related to samples. labels Jul 17, 2022
aribray added 3 commits July 17, 2022 09:48
Change-Id: Ibaa2bd6a9f687b67af61a5f958c37e2faf087434
…alogflow-cx into aribray--close-resources

Change-Id: I9c7293a831c91839c71593967d9718e72be876c6
Change-Id: I60fff4d6c83d42b8921b4ed4ce6c0eea76a952c6
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Jul 17, 2022
Change-Id: I2facb88a81c1d76d5b2316da04cebdffba6634b9
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jul 17, 2022
aribray added 16 commits July 17, 2022 10:18
Change-Id: I0eab8286ac21a8becf64b541100050581016ca5d
Change-Id: I94553a4501a6bdfbdcad1360833cd5e4352d9a77
Change-Id: I123c577193306dc4625d2d56637e71e13cd06f70
Change-Id: I38d51da44e19b7c50d09d3e32aa6b5378c8fc0e2
Change-Id: I8f0b7e31a2283c5dae7c6b377861ee03e8cbe621
Change-Id: I3ee67b4c3ce45b18138d9382fd18f5f4646372db
Change-Id: I10cb37ff93f4c28c1f94d8e221c893fe4b74835a
Change-Id: I9b5f96d7c0ee75745084ed2a277fb9dc8b76a98f
Change-Id: I17eeaf75673cb24682552dd59916c0ad5d68b89a
Change-Id: I001e1bd68b5c0953d2c634239828d81bf2576a25
Change-Id: I1454736df9212b36afcd322ef3ce8c677b3500e8
Change-Id: I10d3750668a4acb9ff18f58fdb4f1a19faf6eacc
Change-Id: I2a56b4f9b558fbebb816fb409fdabff4ee194f2f
Change-Id: I7dd46f9543256427e9d86ab4f60b4806bdb8bd9a
Change-Id: Idb0f4d75d0e7902a666248c48ed4fc54aeef5e59
Change-Id: Ie28023c2bf6422a50dc5e09128ede1e49679c95d
@aribray aribray added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 18, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 18, 2022
@aribray aribray marked this pull request as ready for review July 18, 2022 19:43
aribray added 2 commits July 19, 2022 09:34
…ppets

Change-Id: Ic1acaa6097e972b2db35cca2f5928e826ef08964
…alogflow-cx into aribray--close-resources

Change-Id: I88f2768969608e17e8003edaa88c1c15ee6fc44b
@aribray aribray added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 19, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 19, 2022
@aribray aribray requested a review from lesv July 19, 2022 14:41
Copy link
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

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

A couple of comments and a question -- Otherwise LGTM.

// which automatically calls close().
try (TestCasesClient client = TestCasesClient.create(testCasesSettings)) {
for (TestCaseResult element : client.listTestCaseResults(req.build()).iterateAll()) {
System.out.println(element);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we don't label things?

Copy link
Contributor Author

@aribray aribray Jul 19, 2022

Choose a reason for hiding this comment

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

I don't know the answer to this one, but I think it's a good question. I know that when I write snippets, I use a combination of the snippet style guide and the existing snippets for context. I know the overall style guide just got an update, but now might be a good time to have a language-specific refresh. @kweinmeister, I'll pass this off to you for your thoughts!

aribray added 2 commits July 19, 2022 12:24
Change-Id: I25e7e803c8d0b40e6503b6ed8c5fd1c872c4506b
Change-Id: Id387695b0d86c30c74f796e7f57db6e1f8be43bd
@aribray aribray added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 19, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 19, 2022
@aribray aribray merged commit d07165a into googleapis:main Jul 19, 2022
@aribray aribray deleted the aribray--close-resources branch July 19, 2022 18:26
gcf-merge-on-green bot pushed a commit that referenced this pull request Aug 9, 2022
🤖 I have created a release *beep* *boop*
---


## [0.14.3](v0.14.2...v0.14.3) (2022-07-26)


### Documentation

* **samples:** add try blocks to clean up resources in samples and sample tests ([#521](#521)) ([d07165a](d07165a))
* **samples:** add webhook samples ([#479](#479)) ([c1443ae](c1443ae))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
github-actions bot pushed a commit to googleapis/google-cloud-java that referenced this pull request Aug 9, 2022
🤖 I have created a release *beep* *boop*
---


## [0.14.3](googleapis/java-dialogflow-cx@v0.14.2...v0.14.3) (2022-07-26)


### Documentation

* **samples:** add try blocks to clean up resources in samples and sample tests ([#521](googleapis/java-dialogflow-cx#521)) ([6526525](googleapis/java-dialogflow-cx@6526525))
* **samples:** add webhook samples ([#479](googleapis/java-dialogflow-cx#479)) ([86a3ee5](googleapis/java-dialogflow-cx@86a3ee5))

---
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: dialogflow Issues related to the googleapis/java-dialogflow-cx API. samples Issues that are directly related to samples. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants