From 1f7e7b116b79f603bb847a8c8efbb9f1b70200ed Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 15 Apr 2022 18:50:15 +0000 Subject: [PATCH] [Java] Correct trivial race condition in HumanObjectPeerTest On my (very slow) old armv7 device, HumanObjectPeerTest can fail as `maybe_exchange_peer_messages` will set `ran = false` *after* a message is added to the runqueue, but before it runs, then when we call `process_events` there will be no events to process, then before we get into the `runqueue` `synchronized` block the message will be delivered, causing us to think we're done, even though there are now events pending. Because going around the loop twice is free, we should just not set `ran` to false at the top of `maybe_exchange_peer_messages`. --- src/test/java/org/ldk/HumanObjectPeerTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index 275caf65..64bf97a4 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -678,9 +678,6 @@ class HumanObjectPeerTestInstance { void maybe_exchange_peer_messages(Peer peer1, Peer peer2) { if (!use_nio_peer_handler) { - synchronized (runqueue) { - ran = false; - } while (true) { peer1.peer_manager.process_events(); peer2.peer_manager.process_events(); -- 2.39.5