Copilot commented on code in PR #8688:
URL: https://github.com/apache/hadoop/pull/8688#discussion_r3797807178


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestZKDelegationTokenSecretManager.java:
##########
@@ -551,22 +558,27 @@ public void testCreatingParentContainersIfNeeded() throws 
Exception {
         .build();
     curatorFramework.start();
     ZKDelegationTokenSecretManager.setCurator(curatorFramework);
-    DelegationTokenManager tm1 = new DelegationTokenManager(conf, new 
Text("foo"));
+    try {
+      DelegationTokenManager tm1 = new DelegationTokenManager(conf, new 
Text("foo"));
 
-    // When the init method is called,
-    // the ZKDelegationTokenSecretManager#startThread method will be called,
-    // and the creatingParentContainersIfNeeded will be called to create the 
nameSpace.
-    tm1.init();
+      // When the init method is called,
+      // the ZKDelegationTokenSecretManager#startThread method will be called,
+      // and the creatingParentContainersIfNeeded will be called to create the 
nameSpace.
+      tm1.init();

Review Comment:
   `tm1.destroy()` is only called on the success path; if `tm1.init()` or the 
ZK assertion throws, the secret manager threads may be left running and can 
make subsequent tests flaky. Put `tm1.destroy()` in a `finally` so cleanup 
always happens.
   
   This issue also appears on line 631 of the same file.



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

Reply via email to