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 2fbf2fcef0 ARTEMIS-3928 Fixing intermittent failure after executor's 
change
2fbf2fcef0 is described below

commit 2fbf2fcef0f97e4278dd4bc7b9c40aba8b53ea5a
Author: Clebert Suconic <[email protected]>
AuthorDate: Sat Aug 13 22:09:32 2022 -0400

    ARTEMIS-3928 Fixing intermittent failure after executor's change
---
 .../tests/integration/paging/PagingSendTest.java   | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java
index 2371e9bbd7..381e14e27a 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java
@@ -235,13 +235,25 @@ public class PagingSendTest extends ActiveMQTestBase {
       // Give time Queue.deliverAsync to deliver messages
       Assert.assertTrue("Messages were not propagated to internal 
structures.", waitForMessages(queue, batchSize, 3000));
 
-      checkBatchMessagesAreNotPagedTwice(queue);
+      AtomicInteger errors = new AtomicInteger(0);
+      CountDownLatch done = new CountDownLatch(1);
+
+      queue.getPagingStore().getExecutor().execute(() -> {
+         try {
+            checkBatchMessagesAreNotPagedTwice(queue);
+            for (int i = 0; i < 10; i++) {
+               // execute the same count a couple times. This is to make sure 
the iterators have no impact regardless
+               // the number of times they are called
+               assertEquals(batchSize, processCountThroughIterator(queue));
+            }
 
-      for (int i = 0; i < 10; i++) {
-         // execute the same count a couple times. This is to make sure the 
iterators have no impact regardless
-         // the number of times they are called
-         assertEquals(batchSize, processCountThroughIterator(queue));
-      }
+         } catch (Throwable e) {
+            e.printStackTrace();
+            errors.incrementAndGet();
+         }
+         done.countDown();
+      });
+      Assert.assertEquals(0, errors.get());
 
    }
 
@@ -312,6 +324,7 @@ public class PagingSendTest extends ActiveMQTestBase {
 
       Set<String> messageOrderSet = new HashSet<>();
 
+
       int duplicates = 0;
       while (pageIterator.hasNext()) {
          MessageReference reference = pageIterator.next();
@@ -320,10 +333,11 @@ public class PagingSendTest extends ActiveMQTestBase {
 
          // If add(id) returns true it means that this id was already added to 
this set.  Hence a duplicate is found.
          if (!messageOrderSet.add(id)) {
+            System.out.println("Received a duplicate on " + id);
             duplicates++;
          }
       }
-      assertTrue(duplicates == 0);
+      Assert.assertEquals(0, duplicates);
    }
 
    public boolean waitForMessages(Queue queue, int count, long timeout) throws 
Exception {

Reply via email to