Merge branch '2.3.x' into 2.4.x

Closes gh-24578
This commit is contained in:
Stephane Nicoll 2020-12-21 09:38:37 +01:00
commit 2c0bfb7674
2 changed files with 5 additions and 4 deletions

View File

@ -108,6 +108,7 @@ public final class MeterValue {
* Return a new {@link MeterValue} instance for the given double value. * Return a new {@link MeterValue} instance for the given double value.
* @param value the source value * @param value the source value
* @return a {@link MeterValue} instance * @return a {@link MeterValue} instance
* @since 2.3.0
*/ */
public static MeterValue valueOf(double value) { public static MeterValue valueOf(double value) {
return new MeterValue(value); return new MeterValue(value);
@ -115,9 +116,9 @@ public final class MeterValue {
private static Double safeParseDouble(String value) { private static Double safeParseDouble(String value) {
try { try {
return Double.parseDouble(value); return Double.valueOf(value);
} }
catch (NumberFormatException nfe) { catch (NumberFormatException ex) {
return null; return null;
} }
} }

View File

@ -42,8 +42,8 @@ class MeterValueTests {
@Test @Test
void getValueForDistributionSummaryWhenFromNumberStringShouldReturnDoubleValue() { void getValueForDistributionSummaryWhenFromNumberStringShouldReturnDoubleValue() {
MeterValue meterValue = MeterValue.valueOf("123"); MeterValue meterValue = MeterValue.valueOf("123.42");
assertThat(meterValue.getValue(Type.DISTRIBUTION_SUMMARY)).isEqualTo(123); assertThat(meterValue.getValue(Type.DISTRIBUTION_SUMMARY)).isEqualTo(123.42);
} }
@Test @Test