You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2024/09/06 15:08:48 UTC

(groovy) branch GROOVY_4_0_X updated: Do not use common ForkJoinPool on startup

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new 690527f01c Do not use common ForkJoinPool on startup
690527f01c is described below

commit 690527f01cef0d3b4fac59a1c9affa0d60c27521
Author: Florian Mutter <fl...@fashion-digital.de>
AuthorDate: Thu Sep 5 09:00:13 2024 +0800

    Do not use common ForkJoinPool on startup
    
    If there are other threads blocking this pool groovy might never be able to complete but wait forever.
    
    See https://lists.apache.org/thread/hhxy11oqlpl6phfj945ntxy0c024yd2s
    
    (cherry picked from commit 426a85c85b8394a013a5257287245291dafcdac8)
---
 .../org/codehaus/groovy/vmplugin/v9/Java9.java     | 23 ++++++++--------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
index 218fe87ef8..1c9c01f2d4 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -52,7 +52,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -93,25 +92,19 @@ public class Java9 extends Java8 {
 
         Map<String, Set<String>> result = new LinkedHashMap<>(2048);
         try (GroovyClassLoader gcl = new GroovyClassLoader(this.getClass().getClassLoader())) {
-            CompletableFuture<Map<String, Set<String>>> javaDefaultImportsFuture =
-                    CompletableFuture.supplyAsync(() -> doFindClasses(URI.create("jrt:/modules/java.base/"), "java", javaPackages));
             try {
-                URI gsLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.lang.GroovySystem")).toURI();
-                CompletableFuture<Map<String, Set<String>>> groovyDefaultImportsFuture1 =
-                        CompletableFuture.supplyAsync(() -> doFindClasses(gsLocation, "groovy", groovyPackages));
+                // groovy-core (Java source)
+                URI gcjLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.lang.GroovySystem")).toURI();
+                result.putAll(doFindClasses(gcjLocation, "groovy", groovyPackages));
 
                 // in production environment, groovy-core classes, e.g. `GroovySystem`(java class) and `GrapeIvy`(groovy class) are all packaged in the groovy-core jar file,
                 // but in Groovy development environment, groovy-core classes are distributed in different directories
-                URI giLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.grape.GrapeIvy")).toURI();
-                CompletableFuture<Map<String, Set<String>>> groovyDefaultImportsFuture2 =
-                        gsLocation.equals(giLocation)
-                                ? CompletableFuture.completedFuture(Collections.emptyMap())
-                                : CompletableFuture.supplyAsync(() -> doFindClasses(giLocation, "groovy", groovyPackages));
-
-                result.putAll(groovyDefaultImportsFuture1.get());
-                result.putAll(groovyDefaultImportsFuture2.get());
+                URI gcgLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.beans.ListenerList")).toURI();
+                if (!gcjLocation.equals(gcgLocation)) {
+                    result.putAll(doFindClasses(gcgLocation, "groovy", groovyPackages));
+                }
             } finally {
-                result.putAll(javaDefaultImportsFuture.get());
+                result.putAll(doFindClasses(URI.create("jrt:/modules/java.base/"), "java", javaPackages));
             }
         } catch (Exception ignore) {
             Logger logger = Logger.getLogger(getClass().getName());