Skip to content

Flaky unit test: UdpHeartbeatTest reads the sent count before it is updated #247

Closed

Description

@compot-dev

UdpHeartbeatTest.sendsOneOneEverySecondUntilClosed fails now and then, locally and possibly in CI; it failed 2 of 4 runs of the unit tests in Docker on 2026-10-20 (the other 358 tests pass):

java.lang.AssertionError
    at com.openipc.decoder.UdpHeartbeatTest.sendsOneOneEverySecondUntilClosed(UdpHeartbeatTest.java:102)

Line 102 is assertTrue(h.sent() >= 4);, right after the test has received the 4th packet. The heartbeat counts a packet after send() returns, while the test's receive() can return as soon as the datagram arrives, so the count may still be 3 when it is read. The test races the counter; the heartbeat itself works.

Fix: wait briefly for the count (or assert >= 3 and check the 4th after close()), so the test does not depend on thread timing. Test-only change, no new version (no-release).

Activity

  1. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions