From: Matt Corallo Date: Thu, 28 Jul 2022 03:29:27 +0000 (+0000) Subject: [Java] Fix undefined behavior in HumanObjectPeerTest X-Git-Tag: v0.0.110.1~2^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=a622cc2679ad08a6eacf1c5438f6fc370eb194eb;p=ldk-java [Java] Fix undefined behavior in HumanObjectPeerTest CI somehow convinced the access to custom_messages_to_send to trigger an `ArrayIndexOutOfBoundsException`, which should not be possible except in race cases due to threading issues. Adding the missing synchronized block should address it. --- diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index e2af3043..751f198f 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -1054,7 +1054,9 @@ class HumanObjectPeerTestInstance { // so we cannot exchange custom messages with it if (!use_chan_manager_constructor) { byte[] custom_message_bytes = new byte[]{0x42, 0x44, 0x43, 0x00}; - state.peer1.custom_messages_to_send.add(custom_message_bytes); + synchronized(state.peer1.custom_messages_to_send) { + state.peer1.custom_messages_to_send.add(custom_message_bytes); + } state.peer1.peer_manager.process_events(); synchronized (state.peer2.received_custom_messages) { while (true) {