TheNeuralBit commented on a change in pull request #15306:
URL: https://github.com/apache/beam/pull/15306#discussion_r700545789



##########
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:
       Also this




-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to