NO-JIRA support 0 in human readable byte calculation
This commit is contained in:
parent
1304dbd539
commit
0293d80574
|
@ -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++;
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue