This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new ef3b5fa02c ARTEMIS-4985 message priority occasionally broken
ef3b5fa02c is described below
commit ef3b5fa02c905c503d6b4271b4ce0849600f0215
Author: Justin Bertram <[email protected]>
AuthorDate: Mon Aug 12 13:40:14 2024 -0500
ARTEMIS-4985 message priority occasionally broken
The test in this commit was distilled down from a much more complex
integration test that rarely reproduced the problem. It is short and
sweet and reproduces the problem every time.
The problem exists in the iterator's `remove()` method where it uses
`index` instead of `i` when calculating a new highest priority.
---
.../artemis/utils/collections/PriorityLinkedListImpl.java | 10 ++--------
.../activemq/artemis/core/list/PriorityLinkedListTest.java | 12 ++++++++++++
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java
index 73c2aacf8a..e545b9e9f3 100644
---
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java
+++
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java
@@ -295,14 +295,8 @@ public class PriorityLinkedListImpl<E> implements
PriorityLinkedList<E> {
lastIter.remove();
- // This next statement would be the equivalent of:
- // if (index == highestPriority && levels[index].size() == 0)
- // However we have to keep checking all the previous levels
- // otherwise we would cache a max that will not exist
- // what would make us eventually having hasNext() returning false
- // as a bug
- // Part of the fix for HORNETQ-705
- for (int i = index; i >= 0 && levels[index].size() == 0; i--) {
+ // If the last message in the current priority is removed then find
the next highest
+ for (int i = index; i >= 0 && levels[i].size() == 0; i--) {
highestPriority = i;
}
diff --git
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/list/PriorityLinkedListTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/list/PriorityLinkedListTest.java
index c55e0bf2b8..a7c524ecd7 100644
---
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/list/PriorityLinkedListTest.java
+++
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/list/PriorityLinkedListTest.java
@@ -881,6 +881,18 @@ public final class PriorityLinkedListTest {
iter.remove();
}
+ @Test
+ public void testMixupIterator3() {
+ list.addTail(b, 4);
+ list.addTail(c, 9);
+ LinkedListIterator<Wibble> iter = list.iterator();
+ assertTrue(iter.hasNext());
+ assertEquals(c, iter.next());
+ iter.remove();
+ list.addTail(a, 0);
+ assertTrue(iter.hasNext());
+ assertEquals(b, iter.next());
+ }
@Test
public void testPeek() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact