chrishinds commented on a change in pull request #15306:
URL: https://github.com/apache/beam/pull/15306#discussion_r701668964
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/WriteTables.java
##########
@@ -322,6 +322,36 @@ private JobService getJobService(PipelineOptions
pipelineOptions) throws IOExcep
return jobService;
}
+ @Teardown
+ public void onTeardown() {
+ try {
+ if (datasetService != null) {
+ datasetService.close();
+ datasetService = null;
+ }
+ if (jobService != null) {
+ jobService.close();
+ jobService = null;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private DatasetService getDatasetService(PipelineOptions pipelineOptions)
throws IOException {
+ if (datasetService == null) {
+ datasetService =
bqServices.getDatasetService(pipelineOptions.as(BigQueryOptions.class));
+ }
+ return datasetService;
+ }
+
+ private JobService getJobService(PipelineOptions pipelineOptions) throws
IOException {
+ if (jobService == null) {
+ jobService =
bqServices.getJobService(pipelineOptions.as(BigQueryOptions.class));
+ }
+ return jobService;
+ }
+
Review comment:
I made this change against the v2.31.0 tag, then had to merge-in HEAD
for Github to allow PR creation. Only once I'd pushed the button did I realise
I'd captured irrelevant commits.
Really, really, sorry. What do you recommend?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]