From 25314b1d17261227f2316cd80b407e318add75de Mon Sep 17 00:00:00 2001 From: AsamK Date: Wed, 10 Nov 2021 10:30:24 +0100 Subject: [PATCH] Synchronize plain text output of incoming messages --- src/main/java/org/asamk/signal/ReceiveMessageHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/asamk/signal/ReceiveMessageHandler.java b/src/main/java/org/asamk/signal/ReceiveMessageHandler.java index 26e12809..4e44497f 100644 --- a/src/main/java/org/asamk/signal/ReceiveMessageHandler.java +++ b/src/main/java/org/asamk/signal/ReceiveMessageHandler.java @@ -25,6 +25,12 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler { @Override public void handleMessage(MessageEnvelope envelope, Throwable exception) { + synchronized (writer) { + handleMessageInternal(envelope, exception); + } + } + + private void handleMessageInternal(MessageEnvelope envelope, Throwable exception) { var source = envelope.sourceAddress(); writer.println("Envelope from: {} (device: {})", source.map(this::formatContact).orElse("unknown source"),