keith-turner commented on code in PR #5670:
URL: https://github.com/apache/accumulo/pull/5670#discussion_r2164771140


##########
server/base/src/main/java/org/apache/accumulo/server/util/Admin.java:
##########
@@ -968,19 +968,27 @@ private void executeFateOpsCommand(ServerContext context, 
FateOpsCommand fateOps
       } else if (fateOpsCommand.fail) {
         adminLock = createAdminLock(context);
         fateStores = createFateStores(context, zk, adminLock);
-        for (String fateIdStr : fateOpsCommand.fateIdList) {
-          if (!admin.prepFail(fateStores, fateIdStr)) {
-            throw new AccumuloException("Could not fail transaction: " + 
fateIdStr);
+        try {
+          for (String fateIdStr : fateOpsCommand.fateIdList) {
+            if (!admin.prepFail(fateStores, fateIdStr)) {
+              throw new AccumuloException("Could not fail transaction: " + 
fateIdStr);
+            }
           }
+        } finally {
+          closeFateStores(fateStores.values());
         }
       } else if (fateOpsCommand.delete) {
         adminLock = createAdminLock(context);
         fateStores = createFateStores(context, zk, adminLock);
-        for (String fateIdStr : fateOpsCommand.fateIdList) {
-          if (!admin.prepDelete(fateStores, fateIdStr)) {
-            throw new AccumuloException("Could not delete transaction: " + 
fateIdStr);
+        try {
+          for (String fateIdStr : fateOpsCommand.fateIdList) {
+            if (!admin.prepDelete(fateStores, fateIdStr)) {
+              throw new AccumuloException("Could not delete transaction: " + 
fateIdStr);
+            }
+            admin.deleteLocks(zk, zTableLocksPath, fateIdStr);
           }
-          admin.deleteLocks(zk, zTableLocksPath, fateIdStr);
+        } finally {
+          closeFateStores(fateStores.values());

Review Comment:
   When there is an exception in the try block and then in the finally block, 
java drops the excpetion in the try block.  Could refactor `createFateStores` 
to return somthing that is autocloseable to get better exception handling.
   
   Then could do and drop the finally block.
   
   ```
   try {var fateStores = createFateStores(context, zk, adminLock)){
   }
   ```
   
   If this is a simple change of introducing a simple class, may be worthwhile.



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