jbonofre commented on code in PR #1628:
URL: https://github.com/apache/activemq/pull/1628#discussion_r2720351250
##########
activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java:
##########
@@ -1019,15 +1016,22 @@ public void testAckOfExpired() throws Exception {
Session sendSession = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sendSession.createProducer(destination);
- producer.setTimeToLive(500);
+ final int ttl = 500;
+ producer.setTimeToLive(ttl);
final int count = 4;
for (int i = 0; i < count; i++) {
TextMessage message = sendSession.createTextMessage("" + i);
producer.send(message);
}
// let first bunch in queue expire
- Thread.sleep(1000);
+ final long expiryTime = System.currentTimeMillis() +
TimeUnit.MILLISECONDS.toMillis(ttl * 2L);
+ assertTrue("ttl elapsed", Wait.waitFor(new Wait.Condition() {
Review Comment:
I think `Wait.waitFor()` with a condition (and timeout) is more
efficient/secure compared to `Thread.sleep()`: an arbitrary `Thread.sleep()`
depends of the performance of the machine running the test, whereas
`Wait.waitFor()` is condition "adapting" to the executor performance.
I think we should use a condition here (like the expired count).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact