From f79719beaa74e7c42d30fb7ad9e9e259538d4f32 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sun, 31 Oct 2010 15:47:19 +0200 Subject: [PATCH] fix parsing of bytes value --- .../java/org/elasticsearch/common/unit/ByteSizeValue.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index 69cf870973b..a47e1735658 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -129,9 +129,7 @@ public class ByteSizeValue implements Serializable, Streamable { } long bytes; try { - if (sValue.endsWith("b")) { - bytes = Long.parseLong(sValue.substring(0, sValue.length() - 1)); - } else if (sValue.endsWith("k") || sValue.endsWith("K")) { + if (sValue.endsWith("k") || sValue.endsWith("K")) { bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C1); } else if (sValue.endsWith("kb")) { bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C1); @@ -143,6 +141,8 @@ public class ByteSizeValue implements Serializable, Streamable { bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C3); } else if (sValue.endsWith("gb")) { bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C3); + } else if (sValue.endsWith("b")) { + bytes = Long.parseLong(sValue.substring(0, sValue.length() - 1)); } else { bytes = Long.parseLong(sValue); }