diff --git a/artio-core/src/test/java/uk/co/real_logic/artio/protocol/GatewayPublicationTest.java b/artio-core/src/test/java/uk/co/real_logic/artio/protocol/GatewayPublicationTest.java index 1082e3cd49..e438d7df70 100644 --- a/artio-core/src/test/java/uk/co/real_logic/artio/protocol/GatewayPublicationTest.java +++ b/artio-core/src/test/java/uk/co/real_logic/artio/protocol/GatewayPublicationTest.java @@ -11,6 +11,7 @@ import org.agrona.concurrent.NoOpIdleStrategy; import org.agrona.concurrent.SystemEpochNanoClock; import org.agrona.concurrent.UnsafeBuffer; +import org.junit.jupiter.api.Timeout; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import uk.co.real_logic.artio.messages.DisconnectReason; @@ -38,6 +39,7 @@ static IntStream bodyLengthRange() ); } + @Timeout(2) @ParameterizedTest @MethodSource("bodyLengthRange") void testSavingMessagesOverTermBoundary(final int bodyLength) @@ -74,8 +76,7 @@ void testSavingMessagesOverTermBoundary(final int bodyLength) ThreadLocalRandom.current().nextBytes(body); final DirectBuffer srcBuffer = new UnsafeBuffer(body); - int attempt = 1; - do + while (true) { final long result = gatewayPublication.saveMessage( srcBuffer, @@ -93,13 +94,11 @@ void testSavingMessagesOverTermBoundary(final int bodyLength) { break; } - if (attempt >= 2) + if (Thread.currentThread().isInterrupted()) { fail("failed to save message: " + result); } - attempt++; } - while (true); final MessageCapturingProtocolHandler protocolHandler = new MessageCapturingProtocolHandler(); final ProtocolSubscription protocolSubscription = ProtocolSubscription.of(protocolHandler);