This is an automated email from the ASF dual-hosted git repository.

clebertsuconic 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 684d376da2 ARTEMIS-5173 Avoiding exception on tests
684d376da2 is described below

commit 684d376da22ae71fadc9d17566672c8cf0c28c72
Author: Clebert Suconic <[email protected]>
AuthorDate: Wed Dec 11 16:54:39 2024 -0500

    ARTEMIS-5173 Avoiding exception on tests
---
 .../largemessages/AMQPLargeMessagesTestUtil.java   | 25 ++++++++++------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AMQPLargeMessagesTestUtil.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AMQPLargeMessagesTestUtil.java
index ad15b50245..082c905202 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AMQPLargeMessagesTestUtil.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AMQPLargeMessagesTestUtil.java
@@ -40,21 +40,18 @@ public class AMQPLargeMessagesTestUtil {
 
    public static void validateTemporaryBuffers(Queue serverQueue) {
       LinkedListIterator<MessageReference> totalIterator = 
serverQueue.browserIterator();
-      while (totalIterator.hasNext()) {
-         MessageReference ref;
-         try {
-            ref = totalIterator.next();
-         } catch (NoSuchElementException e) {
-            // that's fine, it means the iterator got to the end of the list
-            // and something else removed it
-            break;
-         }
-         if (ref.getMessage() instanceof AMQPLargeMessage) {
-            AMQPLargeMessage amqpLargeMessage = (AMQPLargeMessage) 
ref.getMessage();
-            // Using a Wait.waitFor here as we may have something working with 
the buffer in parallel
-            Wait.waitFor(() -> amqpLargeMessage.inspectTemporaryBuffer() == 
null, 1000, 10);
-            assertNull(amqpLargeMessage.inspectTemporaryBuffer(), "Temporary 
buffers are being retained");
+      try {
+         while (totalIterator.hasNext()) {
+            MessageReference ref = totalIterator.next();
+            if (ref.getMessage() instanceof AMQPLargeMessage) {
+               AMQPLargeMessage amqpLargeMessage = (AMQPLargeMessage) 
ref.getMessage();
+               // Using a Wait.waitFor here as we may have something working 
with the buffer in parallel
+               Wait.waitFor(() -> amqpLargeMessage.inspectTemporaryBuffer() == 
null, 1000, 10);
+               assertNull(amqpLargeMessage.inspectTemporaryBuffer(), 
"Temporary buffers are being retained");
+            }
          }
+      } catch (NoSuchElementException e) {
+         // that's ok
       }
       totalIterator.close();
    }


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