Skip to content

feat: Add flag change listener support to the contract test service - #240

Draft
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/java-contract-test-listeners
Draft

kinyoklion wants to merge 1 commit into
mainfrom
rlamb/java-contract-test-listeners

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

The Java contract test service did not declare the flag-change-listeners and flag-value-change-listeners capabilities, so the test harness skipped its flag change listener suite for Java. The suite now also covers dependent-flag notifications (sdk-test-harness #514) and override change notifications (#515), and Java should be checked by all of it.

The service now declares both capabilities and handles the three listener commands. ListenerRegistry keeps the listeners the harness has registered with one SDK client, keyed by the harness's listener ID. A general flag change listener is registered with FlagTracker.addFlagChangeListener and posts the flag key of every change event to its callback URI. A flag value change listener uses FlagTracker.addFlagValueChangeListener for the given flag and context and posts the old and new values when the SDK reports a value change. unregisterListener removes the listener and returns 400 for an unknown ID; closing the client removes them all; re-registering an ID replaces the earlier listener. Notifications are posted through the existing HookCallbackService, and a failed post is logged rather than thrown, since the SDK calls listeners from its worker thread.

The Java API has no application default value for a value change listener, so the defaultValue the harness sends is accepted and not used; the harness tests only compare the values of flags that exist.

Verification

Run locally: the released harness listener suite passes against this service, and so does the dependent-flag suite from sdk-test-harness #514 (prerequisite chains, segment and nested segment references, a segment behind a prerequisite, deletions, and full data sets). With this commit cherry-picked onto the flag overrides stack (#225), the override change notification suite from sdk-test-harness #515 passes as well. CI will run the released suite once the capabilities are declared.

The service now declares the flag-change-listeners and
flag-value-change-listeners capabilities and handles the
registerFlagChangeListener, registerFlagValueChangeListener, and
unregisterListener commands. Each registered listener posts a notification
to the callback URI the harness supplies when the SDK fires it, with the old
and new values for a value change listener. Listeners are keyed by the
harness's listener ID, a re-registered ID replaces the earlier listener, and
closing the client removes them all.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c46c68d. Configure here.

This branch has not been deployed

No deployments
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.

1 participant