Copilot commented on code in PR #10478:
URL: https://github.com/apache/ozone/pull/10478#discussion_r3386657332
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -222,6 +223,7 @@ public class RpcClient implements ClientProtocol {
private final MemoizedSupplier<ExecutorService> ecReconstructExecutor;
private final ContainerClientMetrics clientMetrics;
private final MemoizedSupplier<ExecutorService> writeExecutor;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
Review Comment:
Setting `closed` to `true` at the very start of `close()` can prevent
subsequent `close()` calls from completing cleanup if the first `close()` exits
early due to an exception thrown later in the method (since later calls will
now return immediately). A more robust pattern is to (1) guard against
concurrent re-entry (eg with a separate `closing` flag/lock), (2) attempt all
cleanup steps while collecting/deferring exceptions, and (3) only mark `closed
= true` once cleanup has been attempted (eg in a `finally` after the full
shutdown sequence), so failure in one close step doesn’t permanently skip the
remaining cleanup.
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1948,6 +1950,9 @@ private OmKeyInfo getKeyInfo(OmKeyArgs keyArgs) throws
IOException {
@Override
public void close() throws IOException {
+ if (!closed.compareAndSet(false, true)) {
+ return;
+ }
Review Comment:
Setting `closed` to `true` at the very start of `close()` can prevent
subsequent `close()` calls from completing cleanup if the first `close()` exits
early due to an exception thrown later in the method (since later calls will
now return immediately). A more robust pattern is to (1) guard against
concurrent re-entry (eg with a separate `closing` flag/lock), (2) attempt all
cleanup steps while collecting/deferring exceptions, and (3) only mark `closed
= true` once cleanup has been attempted (eg in a `finally` after the full
shutdown sequence), so failure in one close step doesn’t permanently skip the
remaining cleanup.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]