jiajunwang commented on a change in pull request #1077:
URL: https://github.com/apache/helix/pull/1077#discussion_r437648635



##########
File path: 
helix-lock/src/main/java/org/apache/helix/lock/helix/ZKDistributedNonblockingLock.java
##########
@@ -115,6 +113,11 @@ public boolean isCurrentOwner() {
         .getTimeout());
   }
 
+  @Override
+  public void close() {
+    _baseDataAccessor.close();

Review comment:
       You don't call unlock() here?

##########
File path: helix-lock/src/main/java/org/apache/helix/lock/DistributedLock.java
##########
@@ -49,4 +49,9 @@
    * false if the user is not the lock owner or the lock doesn't have a owner
    */
   boolean isCurrentOwner();
+
+  /**
+   * Close the lock and release resources
+   */
+  void close();

Review comment:
       I suggest making this interface AutoClosable, then you implement close() 
naturally.

##########
File path: 
helix-lock/src/test/java/org/apache/helix/lock/helix/TestZKHelixNonblockingLock.java
##########
@@ -71,9 +73,14 @@ public void beforeMethod() {
     Assert.assertFalse(_gZkClient.exists(_lockPath));
   }
 
+  @AfterSuite
+  public void afterSuite() throws IOException {
+    _lock.close();

Review comment:
       Add a test case about close() to validate:
   1. lock released properly. The releases information should be right (if we 
have any).
   2. the connection has been ended.




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

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