Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ public void trackMetric(String eventName, LDContext context, LDValue data, doubl
baseLogger.warn("Track called with null context!");
} else if (!context.isValid()) {
baseLogger.warn("Track called with invalid context: " + context.getError());
} else if (Double.isNaN(metricValue) || Double.isInfinite(metricValue)) {
baseLogger.warn("trackMetric called with non-finite metric value for event \"{}\"; event not recorded",
eventName);
} else {
eventProcessor.recordCustomEvent(context, eventName, data, metricValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public void trackWithInvalidContextDoesNotSendEvent() {
assertEquals(0, eventSink.events.size());
}

@Test
public void trackMetricWithNonFiniteValueDoesNotSendEvent() {
client.trackMetric("eventkey", context, LDValue.of(1), Double.NaN);
client.trackMetric("eventkey", context, LDValue.of(1), Double.POSITIVE_INFINITY);
client.trackMetric("eventkey", context, LDValue.of(1), Double.NEGATIVE_INFINITY);
assertEquals(0, eventSink.events.size());
}

@Test
public void boolVariationSendsEvent() throws Exception {
DataModel.FeatureFlag flag = flagWithValue("key", LDValue.of(true));
Expand Down