]> git.bitcoin.ninja Git - ldk-java/commit
[Java] Correct trivial race condition in HumanObjectPeerTest
authorMatt Corallo <git@bluematt.me>
Fri, 15 Apr 2022 18:50:15 +0000 (18:50 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 15 Apr 2022 18:52:57 +0000 (18:52 +0000)
commit1f7e7b116b79f603bb847a8c8efbb9f1b70200ed
treefea097ee63f7a4ac13217d4de0c99a55888e006b
parent53fabb360246725225c4192c9a43bea725a15d77
[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