Skip to content

Commit e2e1cf4

Browse files
committed
Only check int value if set in hasValue
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 gh-3535
1 parent 46e2bfd commit e2e1cf4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

implementations/micrometer-registry-signalfx/src/test/java/io/micrometer/signalfx/SignalFxMeterRegistryTest.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,13 @@ private static Condition<SignalFxProtocolBuffers.DataPoint> gaugePoint(String na
331331
private static Condition<SignalFxProtocolBuffers.DataPoint> hasValue(double value) {
332332
return new Condition<>(point -> {
333333
SignalFxProtocolBuffers.Datum v = point.getValue();
334-
return v.getDoubleValue() == value || v.getIntValue() == (int) value;
334+
if (v.hasDoubleValue()) {
335+
return v.getDoubleValue() == value;
336+
}
337+
if (v.hasIntValue()) {
338+
return v.getIntValue() == (int) value;
339+
}
340+
return false;
335341
}, "Has value %s", value);
336342
}
337343

0 commit comments

Comments
 (0)