NullReference in DeliveryEndpointUrlBuilder
alanta opened this issue · comments
While investigating an other issue, I came across this bug:
The code incorrectly assumes _deliveryOptionsMonitor
is initialized which is not the case if the object was constructed using the second constructor.
I'd put up a PR for it but I'm not sure if the second constructor is worth having since it's not being referenced in the project at all.
Hello @alanta,
thanks for the report. You are right, that this constructor is not used in this SDK solution. I think proper way to fix this problem is to
- Remove unused constructor
public DeliveryEndpointUrlBuilder(DeliveryOptions deliveryOptions)
, as internally the second one with options monitor is used. This removes one source of null options monitor issue. - Update
CurrentDeliveryOptions
implementation (remove setter and also usage of related private variabledeliveryOptions
). - Mark whole class
DeliveryEndpointUrlBuilder
asinternal
. The fact is, that it is internal code that is strongly tied to Kontent Delivery API routing that is out of standard SDK user control. Therefore I don't expect any customization/usage outside of SDK and there is no point in exposing it aspublic
. - DeliveryClient constructor initialization of variable from its parameter
IOptionsMonitor<DeliveryOptions> deliveryOptions
should be safeguarded byArgumentNullException
to allow detection of invalid options monitor as soon as possible.
We discussed this with @Simply007. I will fix this problem, but in a safer way. I will fix that potential null problem and deprecate public DeliveryEndpointUrlBuilder(DeliveryOptions deliveryOptions)
constructor instead of mentioned points 1-3.
Just FYI, this was released in https://github.com/Kentico/kontent-delivery-sdk-net/releases/tag/16.0.1.