diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java index 697ad746c..c836eda42 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java @@ -1299,6 +1299,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { private static final ConcurrentMap cTimeZoneDisplayCache = new ConcurrentHashMap<>(7); + /** *

Gets the time zone display name, using a cache for performance.

* @@ -1310,16 +1311,8 @@ public class FastDatePrinter implements DatePrinter, Serializable { */ static String getTimeZoneDisplay(final TimeZone tz, final boolean daylight, final int style, final Locale locale) { final TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale); - String value = cTimeZoneDisplayCache.get(key); - if (value == null) { - // This is a very slow call, so cache the results. - value = tz.getDisplayName(daylight, style, locale); - final String prior = cTimeZoneDisplayCache.putIfAbsent(key, value); - if (prior != null) { - value= prior; - } - } - return value; + // This is a very slow call, so cache the results. + return cTimeZoneDisplayCache.computeIfAbsent(key, k -> tz.getDisplayName(daylight, style, locale)); } /**