X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fldk%2FHumanObjectPeerTest.java;fp=src%2Ftest%2Fjava%2Forg%2Fldk%2FHumanObjectPeerTest.java;h=a0879869ff8355c8b1d80c8b8d710315ec0cdc94;hb=29ab9644811732129e29eab532667a7f335fc4f6;hp=484f63b47350d0844c3dbc5d98ee967ab30a4644;hpb=061208bb42db1507495ed74f3d4bbbc2399e45b2;p=ldk-java diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index 484f63b4..a0879869 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -174,6 +174,7 @@ class HumanObjectPeerTestInstance { final HashMap monitors; // Wow I forgot just how terrible Java is - we can't put a byte array here. byte[] node_id; final LinkedList broadcast_set = new LinkedList<>(); + GcCheck obj = new GcCheck(); private TwoTuple test_mon_roundtrip(ChannelMonitor mon) { // Because get_funding_txo() returns an OutPoint in a tuple that is a reference to an OutPoint inside the @@ -683,11 +684,13 @@ class HumanObjectPeerTestInstance { } java.util.LinkedList> must_free_objs = new java.util.LinkedList(); - boolean gc_ran = false; + int gc_count = 0; + int gc_exp_count = 0; class GcCheck { + GcCheck() { gc_exp_count += 1; } @Override protected void finalize() throws Throwable { - gc_ran = true; + gc_count += 1; super.finalize(); } } @@ -701,7 +704,7 @@ public class HumanObjectPeerTest { } void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler) throws InterruptedException { HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler); - while (!instance.gc_ran) { + while (instance.gc_count != instance.gc_exp_count) { System.gc(); System.runFinalization(); }