From cef9ba8c7b6c67505aa96094b338e1adc8521f8b Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Mon, 18 Mar 2024 18:21:41 +0100 Subject: [PATCH] LDEV-2824 - modified the behaviour for maxThreads==1 --- core/src/main/java/lucee/runtime/functions/closure/Each.java | 4 +++- core/src/main/java/lucee/runtime/functions/closure/Every.java | 4 +++- .../src/main/java/lucee/runtime/functions/closure/Filter.java | 4 +++- core/src/main/java/lucee/runtime/functions/closure/Map.java | 4 +++- core/src/main/java/lucee/runtime/functions/closure/Some.java | 4 +++- loader/build.xml | 2 +- loader/pom.xml | 2 +- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/lucee/runtime/functions/closure/Each.java b/core/src/main/java/lucee/runtime/functions/closure/Each.java index ae0337b629..2d29d9d2b4 100644 --- a/core/src/main/java/lucee/runtime/functions/closure/Each.java +++ b/core/src/main/java/lucee/runtime/functions/closure/Each.java @@ -69,7 +69,9 @@ public static String call(PageContext pc, Object obj, UDF udf, boolean parallel, private static String _call(PageContext pc, Object obj, UDF udf, boolean parallel, int maxThreads, short type) throws PageException { ExecutorService execute = null; List>> futures = null; - if (parallel && maxThreads > 1) { + if (maxThreads < 1) maxThreads = 20; + else if (maxThreads == 1) parallel = false; + if (parallel) { execute = Executors.newFixedThreadPool(maxThreads); futures = new ArrayList>>(); } diff --git a/core/src/main/java/lucee/runtime/functions/closure/Every.java b/core/src/main/java/lucee/runtime/functions/closure/Every.java index 10fd102670..6f36705574 100644 --- a/core/src/main/java/lucee/runtime/functions/closure/Every.java +++ b/core/src/main/java/lucee/runtime/functions/closure/Every.java @@ -73,7 +73,9 @@ private static boolean _call(PageContext pc, Object obj, UDF udf, boolean parall ExecutorService execute = null; List>> futures = null; - if (parallel && maxThreads > 1) { + if (maxThreads < 1) maxThreads = 20; + else if (maxThreads == 1) parallel = false; + if (parallel) { execute = Executors.newFixedThreadPool(maxThreads); futures = new ArrayList>>(); } diff --git a/core/src/main/java/lucee/runtime/functions/closure/Filter.java b/core/src/main/java/lucee/runtime/functions/closure/Filter.java index a18cd62dfa..1d31b242be 100644 --- a/core/src/main/java/lucee/runtime/functions/closure/Filter.java +++ b/core/src/main/java/lucee/runtime/functions/closure/Filter.java @@ -79,7 +79,9 @@ private static Collection _call(PageContext pc, Object obj, UDF udf, boolean par ExecutorService execute = null; List>>> futures = null; - if (parallel && maxThreads > 1) { + if (maxThreads < 1) maxThreads = 20; + else if (maxThreads == 1) parallel = false; + if (parallel) { execute = Executors.newFixedThreadPool(maxThreads); futures = new ArrayList>>>(); } diff --git a/core/src/main/java/lucee/runtime/functions/closure/Map.java b/core/src/main/java/lucee/runtime/functions/closure/Map.java index 9419f89f4e..bf8465d29e 100644 --- a/core/src/main/java/lucee/runtime/functions/closure/Map.java +++ b/core/src/main/java/lucee/runtime/functions/closure/Map.java @@ -79,7 +79,9 @@ private static Collection _call(PageContext pc, Object obj, UDF udf, boolean par ExecutorService execute = null; List>> futures = null; - if (parallel && maxThreads > 1) { + if (maxThreads < 1) maxThreads = 20; + else if (maxThreads == 1) parallel = false; + if (parallel) { execute = Executors.newFixedThreadPool(maxThreads); futures = new ArrayList>>(); } diff --git a/core/src/main/java/lucee/runtime/functions/closure/Some.java b/core/src/main/java/lucee/runtime/functions/closure/Some.java index cdddec7727..fc4598f0f6 100644 --- a/core/src/main/java/lucee/runtime/functions/closure/Some.java +++ b/core/src/main/java/lucee/runtime/functions/closure/Some.java @@ -73,7 +73,9 @@ private static boolean _call(PageContext pc, Object obj, UDF udf, boolean parall ExecutorService execute = null; List>> futures = null; - if (parallel && maxThreads > 1) { + if (maxThreads < 1) maxThreads = 20; + else if (maxThreads == 1) parallel = false; + if (parallel) { execute = Executors.newFixedThreadPool(maxThreads); futures = new ArrayList>>(); } diff --git a/loader/build.xml b/loader/build.xml index ef503cf24e..518766ebbd 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 94d8e36ba6..cc3daaff9a 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.0.1.82-SNAPSHOT + 6.0.1.83-SNAPSHOT jar Lucee Loader Build