damondouglas commented on code in PR #29282:
URL: https://github.com/apache/beam/pull/29282#discussion_r1396151514


##########
sdks/java/fn-execution/src/main/java/org/apache/beam/sdk/fn/channel/ManagedChannelFactory.java:
##########
@@ -98,7 +101,23 @@ public ManagedChannel forDescriptor(ApiServiceDescriptor 
apiServiceDescriptor) {
     if (directExecutor) {
       channelBuilder = channelBuilder.directExecutor();
     }
-    return channelBuilder.build();
+    ManagedChannel channel = channelBuilder.build();
+    toClose.add(channel);
+    return channel;
+  }
+
+  public void shutdown() {
+    for (ManagedChannel channel : toClose) {
+      channel.shutdownNow();
+    }
+    for (ManagedChannel channel : toClose) {
+      try {
+        channel.awaitTermination(5, TimeUnit.SECONDS);
+      } catch (InterruptedException exn) {
+        System.err.println("Timed out closing channel: " + exn);

Review Comment:
   Should we use a `org.slf4j.Logger` and `LOG.warn("Timed out closing channel: 
{}", exn")`.  Feel free to resolve this comment if you disagree.



-- 
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]

Reply via email to