Skip to content

Commit 1fe4074

Browse files
committed
fix timing and failure handling in testRestartingExpiry
...which was failing nearly all the time on my laptop - publishing is async, so we don't know when the message has it the server and hence the expiry timer starts. We could introduce a confirm, but it's easier to just use the server restart as an indicator. - when the assertion fails we still need to delete the queue. otherwise other tests using the same queue name, but different params, will fail.
1 parent 3a00b94 commit 1fe4074

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/src/com/rabbitmq/client/test/functional/PerMessageTTL.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public void testRestartingExpiry() throws Exception {
6969
.build(), new byte[]{});
7070
long expiryStartTime = System.currentTimeMillis();
7171
restart();
72-
long timeToExpiry = Integer.parseInt(expiryDelay) - (System.currentTimeMillis() - expiryStartTime);
73-
if (timeToExpiry > 0L) {
74-
Thread.sleep(timeToExpiry);
72+
Thread.sleep(Integer.parseInt(expiryDelay));
73+
try {
74+
assertNull("Message should have expired after broker restart", get());
75+
} finally {
76+
deleteQueue(TTL_QUEUE_NAME);
7577
}
76-
assertNull("Message should have expired after broker restart", get());
77-
deleteQueue(TTL_QUEUE_NAME);
7878
}
7979

8080
}

0 commit comments

Comments
 (0)