activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [activemq-artemis] branch master updated: NO-JIRA support 0 in human readable byte calculation
Date Wed, 08 Jan 2020 18:37:53 GMT
This is an automated email from the ASF dual-hosted git repository.

jbertram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 0293d80  NO-JIRA support 0 in human readable byte calculation
0293d80 is described below

commit 0293d8057441e6bfeb9e6533774862ffc86d74eb
Author: Justin Bertram <jbertram@apache.org>
AuthorDate: Wed Jan 8 12:36:52 2020 -0600

    NO-JIRA support 0 in human readable byte calculation
---
 .../src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java     | 4 ++++
 .../org/apache/activemq/artemis/utils/HumanReadableByteCountTest.java | 1 +
 .../apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java   | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

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 81a329e..59f5ce1 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 d06fc47..028714d 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 eea15f7..4f930b7 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


Mime
View raw message