Skip to content

Commit

Permalink
Only check int value if set in hasValue
Browse files Browse the repository at this point in the history
The logic before could result in the method returning true even if the value did not match due to checking an unset (0) int value against a double value that casts to 0.

Resolves micrometer-metricsgh-3535
  • Loading branch information
shakuzen committed Nov 14, 2022
1 parent 46e2bfd commit e2e1cf4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,13 @@ private static Condition<SignalFxProtocolBuffers.DataPoint> gaugePoint(String na
private static Condition<SignalFxProtocolBuffers.DataPoint> hasValue(double value) {
return new Condition<>(point -> {
SignalFxProtocolBuffers.Datum v = point.getValue();
return v.getDoubleValue() == value || v.getIntValue() == (int) value;
if (v.hasDoubleValue()) {
return v.getDoubleValue() == value;
}
if (v.hasIntValue()) {
return v.getIntValue() == (int) value;
}
return false;
}, "Has value %s", value);
}

Expand Down

0 comments on commit e2e1cf4

Please sign in to comment.