gemini-code-assist[bot] commented on code in PR #39390:
URL: https://github.com/apache/beam/pull/39390#discussion_r3616258501
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ProcessBundleHandler.java:
##########
@@ -767,6 +767,7 @@ public BeamFnApi.InstructionResponse.Builder
trySplit(InstructionRequest request
/** Shutdown the bundles, running the tearDown() functions. */
public void shutdown() throws Exception {
bundleProcessorCache.shutdown();
+ beamFnDataClient.close();
}
Review Comment:

If `bundleProcessorCache.shutdown()` throws an exception,
`beamFnDataClient.close()` will not be called, potentially leaking resources.
Wrapping the shutdown calls in a try-finally block ensures that
`beamFnDataClient.close()` is always executed.
```java
public void shutdown() throws Exception {
try {
bundleProcessorCache.shutdown();
} finally {
beamFnDataClient.close();
}
}
```
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/BeamFnDataGrpcClient.java:
##########
@@ -118,6 +118,18 @@ public void poisonInstructionId(String instructionId) {
}
}
+ @Override
+ public void close() {
+ for (BeamFnDataGrpcMultiplexer client : multiplexerCache.values()) {
+ try {
+ client.close();
+ } catch (Exception e) {
+ // proceed to close other clients
+ }
+ }
Review Comment:

Swallowing exceptions silently during shutdown makes debugging difficult
when multiplexers fail to close properly. It is recommended to log the
exception at a warning level.
```suggestion
for (BeamFnDataGrpcMultiplexer client : multiplexerCache.values()) {
try {
client.close();
} catch (Exception e) {
LOG.warn("Failed to close multiplexer", e);
}
}
```
--
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]