From 08749fcee090f0b36f5899e1207a3333798c8a59 Mon Sep 17 00:00:00 2001 From: AsamK Date: Tue, 21 Apr 2020 20:36:28 +0200 Subject: [PATCH] When sending an end session message clear local session store also if sending message fails --- src/main/java/org/asamk/signal/manager/Manager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index cec04431..b6964917 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -732,7 +732,15 @@ public class Manager implements Signal { SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .asEndSessionMessage(); - sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); + final Collection signalServiceAddresses = getSignalServiceAddresses(recipients); + try { + sendMessageLegacy(messageBuilder, signalServiceAddresses); + } catch (Exception e) { + for (SignalServiceAddress address : signalServiceAddresses) { + handleEndSession(address); + } + throw e; + } } @Override