Skip to content

fix: Accept any numeric tracking event value - #65

Open
kinyoklion wants to merge 1 commit into
mainfrom
devin/1788361015-java-track-metric-value
Open

fix: Accept any numeric tracking event value#65
kinyoklion wants to merge 1 commit into
mainfrom
devin/1788361015-java-track-metric-value

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 2, 2026

Copy link
Copy Markdown
Member

track threw a ClassCastException for a tracking event value which was not a Double.

  • TrackingEventDetails.getValue() is an Optional<Number>, so new MutableTrackingEventDetails(99) (an Integer) reached the provider and failed the (Double) cast before any event was sent.
  • The value is now converted with Number.doubleValue(), which is what the LaunchDarkly trackMetric API takes.
  • Added a test tracking an integer value.
Implementation details

The OpenFeature Java SDK does not constrain the numeric type an application passes, and MutableTrackingEventDetails stores the Number as given, so any of Integer, Long, Float, or BigDecimal reached the cast. Only Double worked.

Testing: the change is covered by ProviderTest.itCanTrackAnIntegerTrackingEventValue. The test suite could not be run on this machine because Maven Central and the Gradle plugin portal answered dependency resolution with HTTP 429 from this network; CI runs the suite.

Link to Devin session: https://app.devin.ai/sessions/fe1eb757fe694ef79f3d09f6307d4b47
Open in Devin Desktop: https://app.devin.ai/desktop/session/fe1eb757fe694ef79f3d09f6307d4b47?variant=devin
Requested by: @kinyoklion


Note

Overview
Fixes track failing with a ClassCastException when TrackingEventDetails carries a metric that is not a Double (for example MutableTrackingEventDetails(99) with an Integer).

The provider now reads Optional<Number> via Number.doubleValue() before calling LaunchDarkly trackMetric, matching the API’s double metric parameter. A unit test asserts integer metrics are forwarded as 99.0.

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

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

@kinyoklion
kinyoklion marked this pull request as ready for review September 4, 2026 20:32
@kinyoklion
kinyoklion requested a review from a team as a code owner September 4, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant