From a9017b87959f60d9070cea4a9d8bed9de3a7088d Mon Sep 17 00:00:00 2001 From: vbBerni Date: Sat, 22 Jun 2019 22:31:48 +0200 Subject: [PATCH] handle storage manager null --- .../ManagedMqttClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs b/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs index b27bead..dc57e40 100644 --- a/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs +++ b/Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs @@ -387,7 +387,10 @@ namespace MQTTnet.Extensions.ManagedClient //removed it, in which case we don't want to do anything. _messageQueue.RemoveFirst(i => i.Id.Equals(message.Id)); } - _storageManager?.RemoveAsync(message).GetAwaiter().GetResult(); + if (_storageManager != null) + { + _storageManager.RemoveAsync(message).GetAwaiter().GetResult(); + } } catch (MqttCommunicationException exception) { @@ -408,7 +411,10 @@ namespace MQTTnet.Extensions.ManagedClient { _messageQueue.RemoveFirst(i => i.Id.Equals(message.Id)); } - _storageManager?.RemoveAsync(message).GetAwaiter().GetResult(); + if (_storageManager != null) + { + _storageManager.RemoveAsync(message).GetAwaiter().GetResult(); + } } } catch (Exception exception)