diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java index b0dc59d0a2..2d3f31b505 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java @@ -108,6 +108,7 @@ public final class MeterValue { * Return a new {@link MeterValue} instance for the given double value. * @param value the source value * @return a {@link MeterValue} instance + * @since 2.3.0 */ public static MeterValue valueOf(double value) { return new MeterValue(value); @@ -115,9 +116,9 @@ public final class MeterValue { private static Double safeParseDouble(String value) { try { - return Double.parseDouble(value); + return Double.valueOf(value); } - catch (NumberFormatException nfe) { + catch (NumberFormatException ex) { return null; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValueTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValueTests.java index 1c1572d168..316eea078b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValueTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValueTests.java @@ -42,8 +42,8 @@ class MeterValueTests { @Test void getValueForDistributionSummaryWhenFromNumberStringShouldReturnDoubleValue() { - MeterValue meterValue = MeterValue.valueOf("123"); - assertThat(meterValue.getValue(Type.DISTRIBUTION_SUMMARY)).isEqualTo(123); + MeterValue meterValue = MeterValue.valueOf("123.42"); + assertThat(meterValue.getValue(Type.DISTRIBUTION_SUMMARY)).isEqualTo(123.42); } @Test