Skip to content

[sdk-platform-java] Update the generated samples to reflect client lifecycle best practices #12376

@lqiu96

Description

@lqiu96

The generated samples in each GAPIC client library show use cases of try-with resources. Example:

* try (NetworkServiceClient networkServiceClient = NetworkServiceClient.create()) {

While this is a good example as a sample to show how a client is created and closed without incurring memory leaks, it may provide our users with an incorrect idea of how to create clients. We expect client libraries to be long-lived and not to be re-created/ closed repeatedly.

We should update the samples with a few options:

  1. Samples are updated to not use try-with-resources
  2. Samples have wording to describe that they are for example purposed and link to the official docs
  3. ... Other options?

High Level Changes:
The samples from the GAPIC clients are generated from the generator. Based on the option we choose, we'll have to update the generator accordingly.

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.samplesIssues that are directly related to samples.type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions