You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/12/04 06:45:13 UTC

[GitHub] [kafka] g1geordie opened a new pull request #9687: MINOR: Move lock method outside try block

g1geordie opened a new pull request #9687:
URL: https://github.com/apache/kafka/pull/9687


   The `Lock.lock` in the try block may cause `Lock.unlock`  throw exception when it throw exception .
   I think it's nice to move  outside although` ReentrantLock.lock` impl doesn't throw exception.
   
   ```
    class X {
      private final ReentrantLock lock = new ReentrantLock();
      // ...
   
      public void m() {
        lock.lock();  // block until condition holds
        try {
          // ... method body
        } finally {
          lock.unlock()
        }
      }
    }
   ```
   pattern recommended by 
   https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/locks/ReentrantLock.html


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [kafka] g1geordie commented on pull request #9687: MINOR: Move lock method outside try block

Posted by GitBox <gi...@apache.org>.
g1geordie commented on pull request #9687:
URL: https://github.com/apache/kafka/pull/9687#issuecomment-738601977


   @chia7712   can you help me to take a look?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [kafka] chia7712 merged pull request #9687: MINOR: Move lock method outside try block

Posted by GitBox <gi...@apache.org>.
chia7712 merged pull request #9687:
URL: https://github.com/apache/kafka/pull/9687


   


----------------------------------------------------------------
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:
users@infra.apache.org