This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 5648bc42e2f618bd230e815eb36964d2fd62d303 Author: Gary Gregory <[email protected]> AuthorDate: Sun Mar 20 14:06:39 2022 -0400 Better concurrency with the Java 8 API ConcurrentMap#computeIfAbsent(). --- .../java/org/apache/commons/lang3/time/FastDateParser.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index 049040b..fea3347 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -653,16 +653,9 @@ public class FastDateParser implements DateParser, Serializable { */ private Strategy getLocaleSpecificStrategy(final int field, final Calendar definingCalendar) { final ConcurrentMap<Locale, Strategy> cache = getCache(field); - Strategy strategy = cache.get(locale); - if (strategy == null) { - strategy = field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) - : new CaseInsensitiveTextStrategy(field, definingCalendar, locale); - final Strategy inCache = cache.putIfAbsent(locale, strategy); - if (inCache != null) { - return inCache; - } - } - return strategy; + return cache.computeIfAbsent(locale, k -> { + return field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) : new CaseInsensitiveTextStrategy(field, definingCalendar, locale); + }); } /**
