diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java index 81a329ed1f..59f5ce1346 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java @@ -451,6 +451,10 @@ public class ByteUtil { } public static String getHumanReadableByteCount(long bytes) { + if (bytes == 0) { + return "0B"; + } + int i = 0; while (i < BYTE_MAGNITUDES.length && BYTE_MAGNITUDES[i] > bytes) { i++; diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/HumanReadableByteCountTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/HumanReadableByteCountTest.java index d06fc47702..028714dd76 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/HumanReadableByteCountTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/HumanReadableByteCountTest.java @@ -27,6 +27,7 @@ public class HumanReadableByteCountTest { public void test() { String[] suffixes = new String[] {"K", "M", "G", "T", "P", "E"}; + assertEquals("0B", ByteUtil.getHumanReadableByteCount(0)); assertEquals("999.0B", ByteUtil.getHumanReadableByteCount(999)); assertEquals("500.0B", ByteUtil.getHumanReadableByteCount(500)); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java index eea15f7bac..4f930b7f0f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java @@ -201,7 +201,7 @@ public final class PagingManagerImpl implements PagingManager { public void tick(long usableSpace, long totalSpace) { diskUsableSpace = usableSpace; diskTotalSpace = totalSpace; - logger.tracef("Tick:: usable space at %f, total space at %f", ByteUtil.getHumanReadableByteCount(usableSpace), ByteUtil.getHumanReadableByteCount(totalSpace)); + logger.tracef("Tick:: usable space at %s, total space at %s", ByteUtil.getHumanReadableByteCount(usableSpace), ByteUtil.getHumanReadableByteCount(totalSpace)); } @Override