launchdarkly / cpp-sdks

C++ Client/Server SDKs
Other
5 stars 3 forks source link

fix: client init state should not regress when data source interrupted #441

Closed cwaldren-ld closed 1 month ago

cwaldren-ld commented 2 months ago

The contract of Initialized() is that it's supposed to return true forever once the client has received some data from LaunchDarkly.

This wasn't correct because Initialized() was delegating to IsInitializedSuccessfully(). This function returned true only for the Valid and Offline states. This is missing Interrupted, which the SDK might be in after having once been Valid.


Besides causing an incorrect result for Initialized() when the SDK's data source was interrupted, this affected logging when calling an evaluation method, emitting an incorrect message :

LaunchDarkly client has not yet been initialized. Returning cached value

Although the action is correct (returning cached value), the reason (has not yet initialized) is wrong. We don't need to log this message at all as an interrupted SDK is normal.

To fix, I've deleted the confusing internal IsInitialized method, which was really a proxy for checking state != initializing. I've modified IsInitializedSuccessfully to return true for Interrupted.