Skip to content

Commit 5e4819b

Browse files
committed
DecimalFormat not thread safe, just use String.format
1 parent ffd4903 commit 5e4819b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tool/sdg/src/main/java/org/openscience/cdk/layout/IdentityTemplateLibrary.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.io.OutputStream;
4646
import java.io.OutputStreamWriter;
4747
import java.text.DecimalFormat;
48-
import java.text.DecimalFormatSymbols;
4948
import java.util.ArrayList;
5049
import java.util.Collection;
5150
import java.util.Collections;
@@ -85,8 +84,6 @@
8584
*/
8685
final class IdentityTemplateLibrary {
8786

88-
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(".##", DecimalFormatSymbols.getInstance(Locale.ROOT));
89-
9087
private final Multimap<String, Point2d[]> templateMap = LinkedListMultimap.create();
9188

9289
private final SmilesGenerator smigen = SmilesGenerator.unique();
@@ -297,9 +294,10 @@ static String encodeCoordinates(Point2d[] points) {
297294
sb.append("|(");
298295
for (Point2d point : points) {
299296
if (sb.length() > 2) sb.append(";");
300-
sb.append(DECIMAL_FORMAT.format(point.x));
297+
DecimalFormat fmt;
298+
sb.append(String.format(Locale.ROOT, "%.5f", point.x));
301299
sb.append(',');
302-
sb.append(DECIMAL_FORMAT.format(point.y));
300+
sb.append(String.format(Locale.ROOT, "%.5f", point.y));
303301
sb.append(',');
304302
}
305303
sb.append(")|");

0 commit comments

Comments
 (0)