This thread is to discuss the racing condition between getMessageCount and Delivery Thread.
Just for convenience I have copied the JIRA description which has some relevant information for this discussion.
QueueManagementTest::testMessageCountOverFullSize has a race condition between getMessageCount and Deliver Thread.
PagingChannelSupport::messageCount is an arithmethic expressions of messageRefs.size() + deliveries.size() + nextPagingOrder - firstPagingOrder
deliveries.size is being controlled by Delivery Thread, determined by DeliveryRunnable that runs as-synchronously on Destination.
While getMessageCount might diverge momentarily it will eventually be fixed as soon as DeliveryRunnable has the appropriate time to send the result to the collection deliveries.
To fix this we would need to synchronize delivery and messageCount somehow, probably adding global lock, what we don' t want to add I assume. So, if this is correct the test has to be fixed somehow.
I have changed the test in such way it will make easier to identify the racing condition. Use tracing in your tests and you will see a retry routine that will eventually pass.
I have talked to Tim...
We will add a sleep in between the receive and the getMessageCount.
This will give Deliver enough time to feed another message into deliveries.size().