Skip to content

fix: Log the isFlagKnown cached-data warning only once per client - #213

Merged
kinyoklion merged 2 commits into
mainfrom
rlamb/log-cached-data-warning-once
Sep 15, 2026
Merged

kinyoklion merged 2 commits into
mainfrom
rlamb/log-cached-data-warning-once

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

While the client is not initialized but the data store already holds data, isFlagKnown logs a warning on every call. A client that stays in that state, for example one serving persisted data before its data source connects, emits that warning for every check, which floods the log without adding information.

The warning now logs once per LDClient instance. The check-and-set uses an AtomicBoolean.compareAndSet, which is lock-free and only runs on the path where the warning may be needed, so normal calls are unaffected. The message says that it is logged once.

The sibling message for an uninitialized store, and the gating condition itself, are unchanged. The evaluation path in this SDK has no equivalent cached-data message, so isFlagKnown is the only site.


Note

Overview
Stops log spam when isFlagKnown runs before the client finishes initializing but the data store already has cached flag data.

LDClient now keeps an AtomicBoolean and uses compareAndSet so the “using last known values from data store” warning is emitted once per client instance; the text notes that it is logged once. Behavior for uninitialized stores (still warn every call and return false) and for flag lookup itself is unchanged.

Adds isFlagKnownLogsCachedDataWarningOnlyOnce to assert two isFlagKnown calls in that state produce a single WARN.

Reviewed by Cursor Bugbot for commit bdf0587. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion
kinyoklion marked this pull request as ready for review September 15, 2026 16:55
@kinyoklion
kinyoklion requested a review from a team as a code owner September 15, 2026 16:55
@kinyoklion
kinyoklion merged commit 48215ba into main Sep 15, 2026
25 checks passed
@kinyoklion
kinyoklion deleted the rlamb/log-cached-data-warning-once branch September 15, 2026 22:21
kinyoklion pushed a commit that referenced this pull request Sep 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.17.1](launchdarkly-java-server-sdk-7.17.0...launchdarkly-java-server-sdk-7.17.1)
(2026-09-15)


### Bug Fixes

* Log the isFlagKnown cached-data warning only once per client
([#213](#213))
([48215ba](48215ba))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Releases `launchdarkly-java-server-sdk` 7.17.1** by bumping the
package version in `.release-please-manifest.json`, `gradle.properties`,
and `Version.SDK_VERSION`, and adding the **7.17.1** changelog entry.
> 
> The release ships the bug fix from
[#213](#213): when
`isFlagKnown` runs before the client is initialized but the data store
already has cached flag data, the **“using last known values from data
store”** warning is emitted **once per `LDClient` instance** instead of
on every call. No other functional changes appear in this diff.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1f9019f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants