Moved check on Options.ValidateFeatures below ThrowIf methods to prevent NullReferenceException (#1800)

* Moved check on Options.ValidateFeatures below ThrowIf methods to prevent NullReferenceException

* Add Unit Test

* Update ReleaseNotes.md

---------

Co-authored-by: Christian <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
Ramon Smits
2023-08-13 18:38:37 +02:00
committed by GitHub
co-authored by Christian
parent 101898695e
commit b1dc8607af
3 changed files with 26 additions and 3 deletions
+3 -3
View File
@@ -321,14 +321,14 @@ namespace MQTTnet.Client
MqttTopicValidator.ThrowIfInvalidSubscribe(topicFilter.Topic);
}
ThrowIfDisposed();
ThrowIfNotConnected();
if (Options.ValidateFeatures)
{
MqttClientSubscribeOptionsValidator.ThrowIfNotSupported(options, _adapter.PacketFormatterAdapter.ProtocolVersion);
}
ThrowIfDisposed();
ThrowIfNotConnected();
var subscribePacket = MqttPacketFactories.Subscribe.Create(options);
subscribePacket.PacketIdentifier = _packetIdentifierProvider.GetNextPacketIdentifier();