Skip to content

Commit 1acfddd

Browse files
committed
GG-19426 Don't use "IgniteVersionUtils.BUILD_TSTAMP_DATE_FORMATTER" concurrently.
1 parent cddc85e commit 1acfddd

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class IgniteVersionUtils {
3232
public static final IgniteProductVersion VER;
3333

3434
/** UTC build date formatter. */
35-
public static final SimpleDateFormat BUILD_TSTAMP_DATE_FORMATTER;
35+
private static final SimpleDateFormat BUILD_TSTAMP_DATE_FORMATTER;
3636

3737
/** Formatted build date. */
3838
public static final String BUILD_TSTAMP_STR;
@@ -74,7 +74,7 @@ public class IgniteVersionUtils {
7474

7575
BUILD_TSTAMP_DATE_FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC"));
7676

77-
BUILD_TSTAMP_STR = BUILD_TSTAMP_DATE_FORMATTER.format(new Date(BUILD_TSTAMP * 1000));
77+
BUILD_TSTAMP_STR = formatBuildTimeStamp(BUILD_TSTAMP * 1000);
7878

7979
COPYRIGHT = BUILD_TSTAMP_STR.substring(0, 4) + " Copyright(C) Apache Software Foundation";
8080

@@ -89,6 +89,17 @@ public class IgniteVersionUtils {
8989
VER = IgniteProductVersion.fromString(VER_STR + '-' + BUILD_TSTAMP + '-' + REV_HASH_STR);
9090
}
9191

92+
/**
93+
* Builds string date representation in "yyyyMMdd" format.
94+
* "synchronized" because it uses {@link SimpleDateFormat} which is not threadsafe.
95+
*
96+
* @param ts Timestamp.
97+
* @return Timestamp date in UTC timezone.
98+
*/
99+
public static synchronized String formatBuildTimeStamp(long ts) {
100+
return BUILD_TSTAMP_DATE_FORMATTER.format(new Date(ts));
101+
}
102+
92103
/**
93104
* Private constructor.
94105
*/

modules/core/src/main/java/org/apache/ignite/lang/IgniteProductVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public int compareToIgnoreTimestamp(@NotNull IgniteProductVersion o) {
258258

259259
/** {@inheritDoc} */
260260
@Override public String toString() {
261-
String revTsStr = IgniteVersionUtils.BUILD_TSTAMP_DATE_FORMATTER.format(new Date(revTs * 1000));
261+
String revTsStr = IgniteVersionUtils.formatBuildTimeStamp(revTs * 1000);
262262

263263
String hash = U.byteArray2HexString(revHash).toLowerCase();
264264

0 commit comments

Comments
 (0)