diff --git a/core/src/main/java/lucee/commons/i18n/FormatUtil.java b/core/src/main/java/lucee/commons/i18n/FormatUtil.java index 5e4c28f8e9..1b0f612183 100644 --- a/core/src/main/java/lucee/commons/i18n/FormatUtil.java +++ b/core/src/main/java/lucee/commons/i18n/FormatUtil.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import lucee.commons.date.TimeZoneConstants; import lucee.commons.io.IOUtil; @@ -121,7 +122,7 @@ public static List getAllFormats(Locale locale, TimeZone timeZ sr = cfmlFormats.get(key); if (sr == null || (formatter = sr.get()) == null) { - formatter = new ArrayList<>(); + formatter = new CopyOnWriteArrayList<>(); for (FormatterWrapper dtf: getCFMLFormats(locale, timeZone, lenient)) { formatter.add(dtf); diff --git a/core/src/main/java/lucee/runtime/op/date/DateCaster.java b/core/src/main/java/lucee/runtime/op/date/DateCaster.java index e60413c404..5fee96e677 100755 --- a/core/src/main/java/lucee/runtime/op/date/DateCaster.java +++ b/core/src/main/java/lucee/runtime/op/date/DateCaster.java @@ -67,10 +67,15 @@ public final class DateCaster { // private static short MODE_MONTH_STR=2; // private static short MODE_NONE=4; private static long DEFAULT_VALUE = Long.MIN_VALUE; - private static DateTimeUtil util = DateTimeUtil.getInstance(); public static boolean classicStyle = false; + private static final int SORT_AFTER_FIRST = 500; + private static final int SORT_AFTER = 10000; + + private static boolean firstCountCheck = true; + private static int countCheck = 0; + /** * converts an Object to a DateTime Object (Advanced but slower) * @@ -295,10 +300,8 @@ public static DateTime toDateTime(Locale locale, String str, TimeZone tz, DateTi return (dt == null) ? defaultValue : dt; } - private static int count = 0; - public static DateTime toDateTimeNew(Locale locale, String str, TimeZone tz, DateTime defaultValue, boolean useCommomDateParserAsWell) { - count++; + countCheck++; str = str.trim(); tz = ThreadLocalPageContext.getTimeZone(tz); @@ -317,16 +320,16 @@ public static DateTime toDateTimeNew(Locale locale, String str, TimeZone tz, Dat } } finally { - if (count > 10) { + if (countCheck > (firstCountCheck ? SORT_AFTER_FIRST : SORT_AFTER)) { synchronized (all) { - if (count > 500) { + if (countCheck > (firstCountCheck ? SORT_AFTER_FIRST : SORT_AFTER)) { all.sort(Comparator.comparingInt(x -> -x.successCount)); - count = 0; + countCheck = 0; + firstCountCheck = false; } } } } - if (useCommomDateParserAsWell) return DateCaster.toDateSimple(str, CONVERTING_TYPE_NONE, true, tz, defaultValue); return defaultValue; } diff --git a/loader/build.xml b/loader/build.xml index c992e3a93d..d93fa3ca81 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 5ea6f81917..624ff7e4db 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.2.0.93-SNAPSHOT + 6.2.0.94-SNAPSHOT jar Lucee Loader Build