Skip to content

Commit

Permalink
GG-19426 Don't use "IgniteVersionUtils.BUILD_TSTAMP_DATE_FORMATTER" c…
Browse files Browse the repository at this point in the history
…oncurrently.
  • Loading branch information
ibessonov committed Jun 11, 2019
1 parent cddc85e commit 1acfddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class IgniteVersionUtils {
public static final IgniteProductVersion VER;

/** UTC build date formatter. */
public static final SimpleDateFormat BUILD_TSTAMP_DATE_FORMATTER;
private static final SimpleDateFormat BUILD_TSTAMP_DATE_FORMATTER;

/** Formatted build date. */
public static final String BUILD_TSTAMP_STR;
Expand Down Expand Up @@ -74,7 +74,7 @@ public class IgniteVersionUtils {

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

BUILD_TSTAMP_STR = BUILD_TSTAMP_DATE_FORMATTER.format(new Date(BUILD_TSTAMP * 1000));
BUILD_TSTAMP_STR = formatBuildTimeStamp(BUILD_TSTAMP * 1000);

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

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

/**
* Builds string date representation in "yyyyMMdd" format.
* "synchronized" because it uses {@link SimpleDateFormat} which is not threadsafe.
*
* @param ts Timestamp.
* @return Timestamp date in UTC timezone.
*/
public static synchronized String formatBuildTimeStamp(long ts) {
return BUILD_TSTAMP_DATE_FORMATTER.format(new Date(ts));
}

/**
* Private constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public int compareToIgnoreTimestamp(@NotNull IgniteProductVersion o) {

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

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

Expand Down

0 comments on commit 1acfddd

Please sign in to comment.