Skip to content

Commit 11f659f

Browse files
author
Myron Scott
committed
avoid thread unsafe formatting
1 parent aa87fa7 commit 11f659f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/com/tc/util/Conversion.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ public class Conversion {
3030

3131
private static final Pattern MEMORY_SIZE_PATTERN = Pattern.compile("[0-9]*([.][0-9]+)? *([bkmg])?");
3232
private static final Pattern SIZE_MODIFIER_PATTERN = Pattern.compile("[bkmg]");
33-
private final static DecimalFormat twoDForm = new DecimalFormat();
3433
private static final byte[] EMPTY_BYTE_ARRAY = new byte[] {};
35-
static {
36-
twoDForm.applyLocalizedPattern("#" + new DecimalFormatSymbols().getDecimalSeparator() + "##");
37-
}
3834

3935
private static int makeInt(byte b3, byte b2, byte b1, byte b0) {
4036
return ((((b3 & 0xff) << 24) | ((b2 & 0xff) << 16) | ((b1 & 0xff) << 8) | ((b0 & 0xff) << 0)));
@@ -416,6 +412,8 @@ public static long memorySizeAsLongBytes(String memorySizeInUnits) throws Metric
416412
}
417413

418414
public static String memoryBytesAsSize(long bytes) throws NumberFormatException {
415+
DecimalFormat twoDForm = new DecimalFormat();
416+
twoDForm.applyLocalizedPattern("#" + new DecimalFormatSymbols().getDecimalSeparator() + "##");
419417
if (bytes < KILO.asBytes()) {
420418
return bytes + "b";
421419
} else if (bytes < MEGA.asBytes()) {

0 commit comments

Comments
 (0)