[ 
https://issues.apache.org/jira/browse/KAFKA-7707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709878#comment-16709878
 ] 

ASF GitHub Bot commented on KAFKA-7707:
---------------------------------------

huangyiminghappy opened a new pull request #6002: KAFKA-7707: clean  the code 
never execute
URL: https://github.com/apache/kafka/pull/6002
 
 
   in the BufferPool,the waiters is locked by ReentrantLock,and the waiters add 
Condition all within the lock,and the waiters remove also within the lock.in 
the waiters there is only one   Condition instance.
   
![image](https://user-images.githubusercontent.com/9736914/49506799-ea662100-f8b9-11e8-9fd8-12e99eb8b079.png)
   and in the finally we have remove the waiters's condition,so in the last we 
use the 
   ```   java
   finally {
               // signal any additional waiters if there is more memory left
               // over for them
               try {
                   if (!(this.nonPooledAvailableMemory == 0 && 
this.free.isEmpty()) && !this.waiters.isEmpty())
                       this.waiters.peekFirst().signal();
               } finally {
                   // Another finally... otherwise find bugs complains
                   lock.unlock();
               }
           }
   ``` 
   can modify like 
   ```   java
   finally {
               lock.unlock();
           }
   ``` 
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Some code is not necessary
> --------------------------
>
>                 Key: KAFKA-7707
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7707
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: huangyiming
>            Priority: Minor
>         Attachments: image-2018-12-05-18-01-46-886.png
>
>
> In the trunk branch in 
> [BufferPool.java|https://github.com/apache/kafka/blob/578205cadd0bf64d671c6c162229c4975081a9d6/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java#L174],
>  i think the code can clean,is not necessary,it will never execute
> {code:java}
> if (!(this.nonPooledAvailableMemory == 0 && this.free.isEmpty()) && 
> !this.waiters.isEmpty())
>     this.waiters.peekFirst().signal();
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to