diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java index c2cacac56ca40..d3891931496c5 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java @@ -32,9 +32,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Field; +import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.charset.StandardCharsets; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -727,14 +727,13 @@ public void testPerTopicExpiredStat() throws Exception { //check value field = PersistentSubscription.class.getDeclaredField("expiryMonitor"); field.setAccessible(true); - NumberFormat nf = NumberFormat.getNumberInstance(); - nf.setMaximumFractionDigits(3); - nf.setRoundingMode(RoundingMode.DOWN); for (int i = 0; i < topicList.size(); i++) { PersistentSubscription subscription = (PersistentSubscription) pulsar.getBrokerService() .getTopicIfExists(topicList.get(i)).get().get().getSubscription(subName); PersistentMessageExpiryMonitor monitor = (PersistentMessageExpiryMonitor) field.get(subscription); - assertEquals(Double.valueOf(nf.format(monitor.getMessageExpiryRate())).doubleValue(), cm.get(i).value); + BigDecimal bigDecimal = BigDecimal.valueOf(monitor.getMessageExpiryRate()); + bigDecimal = bigDecimal.setScale(3, RoundingMode.DOWN); + assertEquals(bigDecimal.doubleValue(), cm.get(i).value); } cm = (List) metrics.get("pulsar_subscription_total_msg_expired");