[ 
https://issues.apache.org/jira/browse/ARTEMIS-4985?focusedWorklogId=929922&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-929922
 ]

ASF GitHub Bot logged work on ARTEMIS-4985:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Aug/24 19:28
            Start Date: 12/Aug/24 19:28
    Worklog Time Spent: 10m 
      Work Description: tabish121 commented on code in PR #5142:
URL: https://github.com/apache/activemq-artemis/pull/5142#discussion_r1714271860


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java:
##########
@@ -54,6 +54,9 @@ public PriorityLinkedListImpl(final int priorities, 
Comparator<E> comparator) {
    }
 
    private void checkHighest(final int priority) {
+      for (int i = levels.length - 1; i >= 0 && levels[i].size() == 0; i--) {

Review Comment:
   Had a look at this and I think this loop is probably not needed if the check 
in the loop in the iterator remove uses the correct exit terms.  Currently in 
the remove it scan s for the next highest but it is checking using the wrong 
variable and always reading from the same collection (index) 
   
   `         for (int i = index; i >= 0 && levels[index].size() == 0; i--) {
               highestPriority = i;
            }
   `
   
   When it should be using the loop variable 'i' so that it exists as soon as a 
non-empty collection is found.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 929922)
    Time Spent: 20m  (was: 10m)

> Message priority occasionally broken
> ------------------------------------
>
>                 Key: ARTEMIS-4985
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4985
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Sometimes a lower priority message may be dispatched before a higher priority 
> message.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to