From 8f8d019b0ca50070dfb90b651e830ce19f8155be Mon Sep 17 00:00:00 2001 From: Dmytro Vyazelenko <696855+vyazelenko@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:10:01 +0200 Subject: [PATCH] [Java] Fix test race. --- .../test/java/io/aeron/UntetheredSubscriptionTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/aeron-system-tests/src/test/java/io/aeron/UntetheredSubscriptionTest.java b/aeron-system-tests/src/test/java/io/aeron/UntetheredSubscriptionTest.java index 8a9feb56b5..e497462288 100644 --- a/aeron-system-tests/src/test/java/io/aeron/UntetheredSubscriptionTest.java +++ b/aeron-system-tests/src/test/java/io/aeron/UntetheredSubscriptionTest.java @@ -41,9 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger; import static java.util.Arrays.asList; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -223,9 +220,10 @@ void shouldRejoinAfterResting(final String channel) aeron.conductorAgentInvoker().invoke(); } + final Image tetheredImage = tetheredSub.imageAtIndex(0); final Image untetheredImage = untetheredSub.imageAtIndex(0); - assertThat(untetheredImage.position(), lessThan(publication.position())); - while (untetheredImage.position() < publication.position()) + while (untetheredImage.position() < publication.position() || + tetheredImage.position() < publication.position()) { int fragments = 0; fragments += tetheredSub.poll(fragmentHandler, FRAGMENT_COUNT_LIMIT); @@ -236,7 +234,6 @@ void shouldRejoinAfterResting(final String channel) aeron.conductorAgentInvoker().invoke(); } } - assertEquals(publication.position(), tetheredSub.imageAtIndex(0).position()); } } }