Skip to content
Permalink
Browse files
ARTEMIS-3928 Fixing intermittent failure after executor's change
  • Loading branch information
clebertsuconic committed Aug 14, 2022
1 parent 252e5b0 commit 2fbf2fcef0f97e4278dd4bc7b9c40aba8b53ea5a
Showing 1 changed file with 21 additions and 7 deletions.
@@ -235,13 +235,25 @@ public void testPagingDoesNotDuplicateBatchMessages() throws Exception {
// 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 void checkBatchMessagesAreNotPagedTwice(Queue queue) throws Exception {

Set<String> messageOrderSet = new HashSet<>();


int duplicates = 0;
while (pageIterator.hasNext()) {
MessageReference reference = pageIterator.next();
@@ -320,10 +333,11 @@ public void checkBatchMessagesAreNotPagedTwice(Queue queue) throws Exception {

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

0 comments on commit 2fbf2fc

Please sign in to comment.