From a622cc2679ad08a6eacf1c5438f6fc370eb194eb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 28 Jul 2022 03:29:27 +0000 Subject: [PATCH] [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. --- src/test/java/org/ldk/HumanObjectPeerTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { -- 2.39.5