poorbarcode opened a new pull request, #24634:
URL: https://github.com/apache/pulsar/pull/24634

   ### Motivation
   
   https://github.com/apache/pulsar/pull/23795 improved the method 
`recentlyJoinedConsumers`: rather than check ordering for all items, just check 
the latest two because the method will be called after addition for all 
consumers.
   
   The method `sortRecentlyJoinedConsumersIfNeeded` has a bug; it did an 
unnecessary sorting for the collection `recentlyJoinedConsumers`, and printed 
noisy logs
   
   For example:
   - there are `3` items: `[1, 2, 3]`
   - the first loop:  `posPre` -> `1`
   - the second loop: `posPre` -> `null`; `posAfter` -> `2`
   - the latest loop: `posPre` -> `3`; Since the variable `posPre` is null , 
skip to set the variable `posAfter`
   
   ```java
           // Record the second latest item.
           Position posPre = null;
           // Record the latest item.
           Position posAfter = null;
           for (Map.Entry<Consumer, Position> entry : 
recentlyJoinedConsumers.entrySet()) {
               if (posPre == null) {
                   posPre = entry.getValue();
               } else {
                   posPre = posAfter;
                   posAfter = entry.getValue();
               }
           }
   ```
   
   ### Modifications
   
   Fix the issue.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: x
   


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